Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Tornado script #133

Merged
merged 3 commits into from
Feb 24, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ CPU Cores: 8
- [sanic](https://github.com/channelcat/sanic)
- [japronto](https://github.com/squeaky-pl/japronto)
- [flask](https://github.com/pallets/flask)
- [tornado](https://github.com/tornadoweb/tornado)
- Nim
- [Jester](https://github.com/dom96/jester)
- Objective-C
Expand Down
1 change: 1 addition & 0 deletions python/tornado/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tornado==4.5.3
39 changes: 39 additions & 0 deletions python/tornado/server_python_tornado.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web

from tornado.options import define, options
define('port', default=8000, help='run on the given port', type=int)


class MainHandler(tornado.web.RequestHandler):

def get(self):
self.write('')


class UserHandler(tornado.web.RequestHandler):

def post(self):
self.write('')


class UserInfoHandler(tornado.web.RequestHandler):

def get(self, id):
self.write(id)


if __name__ == '__main__':
options.logging = None
tornado.options.parse_command_line()
app = tornado.web.Application(handlers=[(r'/', MainHandler),
(r"/user", UserHandler),
(r"/user/(\d+)", UserInfoHandler)])
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(options.port)
tornado.ioloop.IOLoop.current().start()