-
Notifications
You must be signed in to change notification settings - Fork 51
/
app.py
executable file
·65 lines (46 loc) · 1.64 KB
/
app.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
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
import os
from flask import Flask, make_response, render_template
from glob import glob
from werkzeug.debug import DebuggedApplication
import app_config
import copytext
import graphic
import graphic_templates
import oauth
from render_utils import make_context
app = Flask(app_config.PROJECT_SLUG)
app.debug = app_config.DEBUG
@app.route('/')
def _graphics_list():
"""
Renders a list of all graphics for local testing.
"""
context = make_context()
context['graphics'] = []
context['templates'] = []
graphics = glob('%s/*' % app_config.GRAPHICS_PATH)
for graphic in graphics:
name = graphic.split('%s/' % app_config.GRAPHICS_PATH)[1].split('/child.html')[0]
context['graphics'].append(name)
context['graphics'].sort();
context['graphics_count'] = len(context['graphics'])
templates = glob('%s/*' % app_config.TEMPLATES_PATH)
for template in templates:
name = template.split('%s/' % app_config.TEMPLATES_PATH)[1]
if name.startswith('_'):
continue
context['templates'].append(name)
context['templates'].sort()
context['templates_count'] = len(context['templates'])
return make_response(render_template('index.html', **context))
app.register_blueprint(graphic.graphic, url_prefix='/graphics')
app.register_blueprint(graphic_templates.graphic_templates, url_prefix='/templates')
app.register_blueprint(oauth.oauth)
if app_config.DEBUG:
wsgi_app = DebuggedApplication(app, evalex=False)
else:
wsgi_app = app
# Boilerplate
if __name__ == '__main__':
print 'This command has been removed! Please run "fab app" instead!'