Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.py
More file actions
Latest commit
31 lines (25 loc) · 813 Bytes
/
Copy pathapp.py
File metadata and controls
31 lines (25 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
fromtornado.optionsimportdefine, options
importtornado.ioloop
importtornado.web
importtornado.httpserver
classMainHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
defget(self):
self._async_callback()
def_async_callback(self):
self.write("Hello, world!")
self.finish()
app=tornado.web.Application([
(r"/", MainHandler),
])
define("port", default="5555", help="Port to listen on")
if__name__=="__main__":
tornado.options.parse_command_line()
server=tornado.httpserver.HTTPServer(app)
server.bind(options.port)
# autodetect cpu cores and fork one process per core
try:
server.start(0)
tornado.ioloop.IOLoop.instance().start()
exceptKeyboardInterrupt:
tornado.ioloop.IOLoop.instance().stop()