-
Notifications
You must be signed in to change notification settings - Fork 7
/
flasfka-serve
executable file
·53 lines (46 loc) · 1.57 KB
/
flasfka-serve
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
50
51
52
53
#!/usr/bin/python2
# -*- coding: utf-8 -*-
import os
import sys
# try to load a virtualenv from the PYTHON_VIRTUALENV environment
# variable, or from the directory "venv"
try:
venv = os.getenv("PYTHON_VIRTUALENV", "venv") + "/bin/activate_this.py"
if sys.version_info.major == 2:
execfile(venv, dict(__file__=venv))
if sys.version_info.major == 3:
with open(venv, 'rb') as f:
exec(compile(f.read(), venv, 'exec'), dict(__file__=venv))
except IOError:
pass
import argparse
from werkzeug.contrib.profiler import ProfilerMiddleware
from flasfka import app
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="flasfka")
parser.add_argument(
"-d", "--debug", action="store_true", help="start in debug mode",
default=False
)
parser.add_argument(
"-p", "--port", action="store", type=int, help="port number",
default=5000
)
parser.add_argument(
"-o", "--profile", action="store_true", help="do profiling",
default=False
)
parser.add_argument(
"-t", "--test", action="store_true", help="launch the test suite",
default=False
)
args = parser.parse_args()
if args.test:
import flasfka
import unittest
unittest.main(module="flasfka.tests",
argv=["flasfka-serve"], verbosity=2)
if args.profile:
app.config["PROFILE"] = True
app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30])
app.run(debug=args.debug, host="127.0.0.1", port=args.port)