-
Notifications
You must be signed in to change notification settings - Fork 21
/
main.py
executable file
·41 lines (29 loc) · 1 KB
/
main.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
31
32
33
34
35
36
37
38
39
40
41
import os
import sys
import tornado
import tornado.web
from tornado.options import define, options
class Application(tornado.web.Application):
def __init__(self):
kwargs = dict(
template_path=os.path.join(os.path.dirname(__file__), 'src/templates'),
static_path=os.path.join(os.path.dirname(__file__), 'src'),
)
self._handlers = [
(r"/(.*)", tornado.web.StaticFileHandler,
dict(
path=kwargs['static_path'],
default_filename='templates/index.html',
),
),
]
super(Application, self).__init__(self._handlers, **kwargs)
def main():
define('port', default=80, help='Runs the webserver on any given port.', type=int)
tornado.options.parse_command_line()
server = tornado.httpserver.HTTPServer(Application())
server.listen(options.port)
tornado.ioloop.IOLoop.current().start()
return 0
if __name__ == '__main__':
sys.exit(main())