The demo application can be accessed at http://pcqdemoapp.appspot.com. All applications for App Engine are hosted on appspot.com
The following code snippet shows the main.html file which will be used as template for our web application.
PCQ Demo Guest Book App {% for guestbook in guestbooks %} {{guestbook.message}} from {% ifequal guestbook.sender "" %} Anonymous {% else %} {{guestbook.sender}} {% endifequal %} {% endfor %} From: Message:
From:
Message:
The main.html template will use Django template engine to render the Web page. Using the script we first loop through the guestbooks list that we have passed along as a parameter in the GET method when we called the template.
Deploying on App Engine When we are done with the writing the application, we can test the Web app on the web server provided with the SDK. To start the web server use the dev_ appserver. py command by giving it the path to the guestbook directory. The command will be like this:
dev_appserver.py c:/guestbook
The web server would be up, and ready to listen requests on port 8080. To test the webapp, type the URL http://localhost:8080 in your browser. Even if you do changes in the web application code, you will not have to restart the Web server, the changes will reflect as soon as you refresh the browser page. Since, we are using a Google's datastore to save the comments on the guestbook. So each time when you use the guestbook application, the comments from the previous session won't be lost. But if we want to clear the comment history from the server we have to pass the option when we start the server as follows:
dev_appserver.py ?clear_datastore c:/guestbook
Now you can upload and deploy this application on Google App Engine. For that first we need to register at appengine.google.com website. Sign in into App Engine using your Google account or create a new one. Now through the App Engine Administration Console, click the ?Create an Application? button and register a unique application name for your Webapp. This application ID will become the URL for your webapp if you elect to host your application on appspot.com. For our guestbook application we registered the application with ID ?pcqdemoapp?. Therefore the URL for that is:
pcqdemoapp.appspot.com
You can access the demo app at this address. Now to upload the guestbook application, first edit the app.yaml file. Change the value of the application: setting from guestbook to your registered application ID. Through the command line, run the following command:
appcfg.py update c:/guestbook
Enter your Google ID and password when prompted and when the update has been made, you can access your application by prefixing your application ID before appspot.com and enter that as your URL.
Thus, we can create apps to be hosted on the Google cloud using App Engine SDK.
Get most out of your technology infrastructure investments with Dell
About CIOL | Media Kit | Site Map | Contact Us | Help | Write to us | Jobs@CyberMedia | Privacy Policy
Copyright © CyberMedia India Online Ltd. All rights reserved. Usage of content from web site is subject to Terms and Conditions.