-
Notifications
You must be signed in to change notification settings - Fork 48
/
main.py
53 lines (42 loc) · 1.28 KB
/
main.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
50
51
52
53
import os
from app import app
from app import app_config
from config import constants
from util import patches
from util.context import create_contexts
from flask_compress import Compress
from views import web_views
from views import campaign_views
from flask_migrate import Migrate
from database import db
# Silence pyflakes
assert patches
assert web_views
assert campaign_views
# enable gzip since it's not supported out of the box on Heroku
Compress(app)
app_config.init_prod_app(app)
# Template context processors
create_contexts(app)
migrate = Migrate(app, db)
if __name__ == '__main__':
# speeds up development by auto-restarting the server when templates change
if constants.DEBUG:
extra_dirs = ['templates',]
extra_files = extra_dirs[:]
for extra_dir in extra_dirs:
for dirname, dirs, files in os.walk(extra_dir):
for filename in files:
filename = os.path.join(dirname, filename)
if os.path.isfile(filename):
extra_files.append(filename)
else:
extra_files=None
app.debug = constants.DEBUG
port = int(os.environ.get("PORT", 5002))
app.run(
host='0.0.0.0',
port=port,
threaded=True,
extra_files=extra_files
)