-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.py
35 lines (29 loc) · 880 Bytes
/
server.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/env python
# -*- coding:utf-8 -*-
import tornado.options
import tornado.ioloop
import tornado.web
import tornado.wsgi
import wsgiref.simple_server
from config.common import DEBUG
from config.websrv import settings
from config.websrv import handlers
def main():
try:
app = tornado.web.Application(handlers, debug=DEBUG, **settings)
print("[*] Server run at %s" % tornado.options.options.url)
if True:
app.listen(tornado.options.options.port)
tornado.ioloop.IOLoop.instance().start()
else:
# reserve for wsgi
server = wsgiref.simple_server.make_server('', 8888, app)
server.serve_forever()
except Exception as e:
import traceback
print(traceback.print_exc())
finally:
import sys
sys.exit(0)
if __name__ == "__main__":
main()