-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
executable file
·34 lines (28 loc) · 1.08 KB
/
run.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
from tornado.ioloop import IOLoop
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from werkzeug.serving import run_simple
from osrc import create_app
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-p", "--port", default=3031, type=int,
help="the port to expose")
parser.add_argument("-d", "--debug", action="store_true",
help="debugging interface")
parser.add_argument("-f", "--filename",
default=None,
help="a Python file with the app settings")
args = parser.parse_args()
print("port: {0}".format(args.port))
print("config: {0}".format(args.filename))
app = create_app(args.filename)
if args.debug:
run_simple("0.0.0.0", args.port, app, use_reloader=True,
use_debugger=True)
else:
http_server = HTTPServer(WSGIContainer(app))
http_server.listen(args.port)
IOLoop.instance().start()