-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
31 lines (25 loc) · 980 Bytes
/
app.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/10/9 22:23
import os
import tornado.web
from tornado.options import define, options
from my_blog.url import urls
import logging
define("port", default=20302, help="run on the given port", type=int)
if __name__ == "__main__":
tornado.options.parse_command_line()
app = tornado.web.Application(
handlers=urls,
debug=True,
template_path=os.path.join(os.path.dirname(__file__), 'templates'),
static_path=os.path.join(os.path.dirname(__file__), 'static'),
)
try:
logging.info('Server is running at http://{host}:{port}'.format(host='127.0.0.1', port=20302))
#app.listen(options.port, xheaders=True, max_body_size=1024 * 1024)
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()
except KeyboardInterrupt:
tornado.ioloop.IOLoop.instance().stop()