-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.py
More file actions
31 lines (25 loc) · 813 Bytes
/
app.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
from tornado.options import define, options
import tornado.ioloop
import tornado.web
import tornado.httpserver
class MainHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
def get(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()
except KeyboardInterrupt:
tornado.ioloop.IOLoop.instance().stop()