hello_world2.py

Send to Kindle
home » snippets » appengine » hello_world2 » hello_world2.py


from google.appengine.ext.webapp.util import run_wsgi_app

import pprint
pp = pprint.pprint
pf = pprint.pformat
import webob


import routes_wsgi
WebobDispatchRule = routes_wsgi.WebobDispatchRule


def main_app(request, **kwargs):
  response = webob.Response()
  response.content_language = ["en"]
  response.content_type = "text/plain"
  response.charset = "utf8"
  response.unicode_body = u"Hello, world"
  response.unicode_body += u"\n\n" + pprint.pformat(kwargs, indent=4)
  response.unicode_body += u"\n\n" + pprint.pformat(request.headers, indent=4)
  response.unicode_body += u"\n\n" + pprint.pformat(request.environ, indent=4)
  return response

wsgi_app = routes_wsgi.get_middleware_app([
  WebobDispatchRule('main', '/', main_app)])


def main():
  run_wsgi_app(wsgi_app)

if __name__ == "__main__":
  main()