Python webapp2 framework and Google App Engine (ongoing)

Google app engine is using the app engine python SDK.

you can download it by here

The Python SDK includes a web  server application that simulates the App Engine environment, including a local version of the data store, Google Accounts and the ability to send and receive e-mails directly.

Notes: Python SDK is not compatible with Python 3. In Linux there is no GUI.

Two basic commands we will be using are:

dev_appserver.py
appcfg.py


Step 1.

create a directory and inside it create a python file filled with the following code:

import webapp2

class MainPage(webapp2.RequestHandler):

def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello, World!')


application = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)


Step 2. Inside the same directory create a file " app.yaml" with the following code. This is the applications configuration file.


application: your-app-id
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
script: helloworld.application


The syntax of this file is YAML.


Step 3. Start the web server (inside the google_appengine dir) with the following command, giving it the path to the helloworld directory:


python dev_appserver.py helloworld/


The web server is now running, listening for requests on port 8080. You can test the application by visiting the following URL in your web browser:

http://localhost:8080/


If you have succeeded you should see the following screen displaying the message you selected.







The procedure above is iterative, which means that any changes will be automatically uploaded to the server and by refreshing the page will be displayed. So you will probably want  the server running..

-------------------------------------------------------------------------------------------------------------
This tutorial is an  implementation  of this walk-through.

No comments:

Post a Comment


Free online chess

View Kapellas Nick's profile on LinkedIn
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License