0:96660b4682ba
Anton Shestakov <engored@ya.ru>, Sat, 12 Jan 2013 15:36:36 +0900
New repo for experiments. First two occupants: async-http-demo and http-methods-demo.

next change 3:195699406124

http-methods-demo/server.py

Permissions: -rwxr-xr-x

Other formats: Feeds:
#!/usr/bin/env python
import logging
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define, options
define('port', default=8888, help='run on the given port', type=int)
class MethodHandler(tornado.web.RequestHandler):
def get(self):
self.finish({'success': True, 'method': 'GET'})
def head(self):
self.finish({'success': True, 'method': 'HEAD'})
def post(self):
self.finish({'success': True, 'method': 'POST'})
def put(self):
self.finish({'success': True, 'method': 'PUT'})
def delete(self):
self.finish({'success': True, 'method': 'DELETE'})
class MethodServer(tornado.web.Application):
def __init__(self):
handlers = [(r'/', MethodHandler)]
tornado.web.Application.__init__(self, handlers)
logging.info('Server started')
def main():
tornado.options.parse_command_line()
http_server = tornado.httpserver.HTTPServer(MethodServer())
http_server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()
if __name__ == '__main__':
main()