annotate makeitso/python_package/{{package}}/web.py @ 214:1a7ed3c940b9

note to self
author Jeff Hammel <k0scist@gmail.com>
date Fri, 04 Dec 2015 11:05:16 -0800
parents 5964dabba04a
children 745c785b6986
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
83
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/usr/bin/env python
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 """
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 web handler for {{project}}
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 """
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6
118
5964dabba04a correct syntax error
Jeff Hammel <jhammel@mozilla.com>
parents: 83
diff changeset
7 from webob import Request, Response, exc
83
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 class Handler(object):
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 def __init__(self, **kw):
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 pass
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14 def __call__(self, environ, start_response):
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15 request = Request(environ)
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16 response = Response(content_type='text/plain',
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17 body="{{project}}")
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18 return response(environ, start_response)
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 if __name__ == '__main__':
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 from wsgiref import simple_server
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22 app = Handler()
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23 server = simple_server.make_server(host='0.0.0.0', port=8080, app=app)
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24 server.serve_forever()
dc51bd3b8f6a add a sample web handler
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25