-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.py
35 lines (29 loc) · 922 Bytes
/
web.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
#! /usr/bin/python3
import os
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.options import define, options
from tornado.web import Application
from tornado.log import enable_pretty_logging
from view import MainHandler, HelloWorld
# Start webserver
def main():
"""Construct and serve the tornado application."""
define('port', default=8000, help='port to listen on')
enable_pretty_logging()
app = Application(
[
('/', MainHandler),
('/helloworld', HelloWorld)
],
static_path=os.path.join(os.path.dirname(__file__), "static"),
debug=True
)
http_server = HTTPServer(app)
http_server.listen(options.port)
print('Listening on http://localhost:%i' % options.port)
IOLoop.current().start()
if __name__ == "__main__":
print("Webserver Starting...")
main()
print("Webserve End")