Create following files in a directory by name helloWorldthis setup is public on c9.io; to see click here
main.py
1 2 3 4 5 6 7 8 9 10 11 | import webapp2 class MainPage(webapp2.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/plain' self.response.write('Hello, World!') app = webapp2.WSGIApplication([ ('/', MainPage), ], debug=True) |
main_test.py
1 2 3 4 5 6 7 8 9 10 11 12 | import webtest import main def test_get(): app = webtest.TestApp(main.app) response = app.get('/') assert response.status_int == 200 assert response.body == 'Hello, World!' |
app.yaml
1 2 3 4 5 6 7 | runtime: python27 api_version: 1 threadsafe: true handlers: - url: /.* script: main.app |
Run your project as follows :
python googleAppEngineSDK/google_appengine/dev_appserver.py --host $IP --port 8081 --admin_host $IP --admin_port 8082 projects/helloWorld