-
Notifications
You must be signed in to change notification settings - Fork 1
/
manage.py
49 lines (40 loc) · 1.47 KB
/
manage.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
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
__author__ = 'croxis'
import os
import sys
from app import create_app, get_scocket
from flask.ext.script import Server, Manager, Shell
import eventlet
eventlet.monkey_patch()
# Manually adding mtgencode to path because hardcast sixdrop is a jerk for not
# adding __init__.py!
sys.path.append('./mtgencode/lib')
sys.path.append('./mtgencode')
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
socketio = get_scocket()
manager = Manager(app)
def make_shell_context():
return dict(app=app)
class Run(Server):
def __call__(self, app, host, port, use_debugger, use_reloader,
threaded, processes, passthrough_errors):
# we don't need to run the server in request context
# so just run it directly
if use_debugger is None:
use_debugger = app.debug
if use_debugger is None:
use_debugger = True
if sys.stderr.isatty():
print(
"Debugging is on. DANGER: Do not allow random users to connect to this server.",
file=sys.stderr)
if use_reloader is None:
use_reloader = app.debug
socketio.run(host=host,
port=port,
use_reloader=use_reloader,
**self.server_options)
manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("run", Run())
if __name__ == '__main__':
manager.run()