What is GAE?
Google App Engine (often referred to as GAE or simply App Engine) is a platform as a service (PaaS) cloud computing platform for developing and hosting web applications in Google-managed data centers. Applications are sandboxed and run across multiple servers.App Engine offers automatic scaling for web applications—as the number of requests increases for an application, App Engine automatically allocates more resources for the web application to handle the additional demand.
We can upload any kind of web applications developed in any programming language like Java, Python, PHP.... etc.,Here in this blog let us see how to upload a simple Django application into the Google App Engine.
Simple procedure to upload a Simple django applicaion to GAE:
STEP 1:First create a simple PyDev Google App Engine Project by following the steps given below.
STEP 2:Creating a Django Project folder:
main.py:
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
settings.py:
ROOT_URLCONF = 'Project_Name.urls'
manage.py:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Project_Name.settings")
app.yaml:
application: django-demoapp
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: main.application
libraries:
- name: django
version: "1.4"
env_variables:
DJANGO_SETTINGS_MODULE: 'Project_Name.settings'
STEP 3:Creating your Django application folder:
Creating a Simple Application to show "Hello MicroPyramid"
To create our application, we would proceed with the following steps:
Create an application folder In the root project folder (together with main.py and manage.py and at the same level with Project_Name folder). A folder with an __init__.py is created as a result.
we will define our requierd views here.Here is the simple view that returns a simple Httpresponse to print "Hello MicroPyramid".
from django.http import HttpResponse
def home(request):
return HttpResponse("hello welcome to google app engine")
We would define a URL to serve the view home. We first modify the urls.py file in the Project_Name package to direct all requests to your application:
from django.conf.urls.defaults import *
urlpatterns = patterns('',
(r'^', include('firapp.urls')),
)
We would then create another PyDev module urls (which is just a fileurls.py) in the firapp package to process all requests related to your application:
from django.conf.urls.defaults import *
from firapp.views import home
urlpatterns = patterns('',
(r'^home/$', home),
)
STEP 4:To Test Run Your Application
Our application would run on the bundled Google Appp Engine development server.
STEP 5:To Deploy Your Application
These steps would deploy your application to the real system.