-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathapp.py
More file actions
59 lines (43 loc) · 1.33 KB
/
app.py
File metadata and controls
59 lines (43 loc) · 1.33 KB
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
import os
from flask import Flask, abort
from flask import render_template
from flaskext.markdown import Markdown
app = Flask(__name__)
# Flask extensions
Markdown(app)
# Enviromental variables
app.config.TYPEKIT_KEY = os.environ.get('TYPEKIT_KEY', None)
app.config.GOOGLE_ANALYTICS_TOKEN = os.environ.get('GOOGLE_ANALYTICS_TOKEN', None)
app.config.GOOGLE_ANALYTICS_DOMAIN = os.environ.get('GOOGLE_ANALYTICS_TOKEN', None)
## Error views
@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html'), 404
@app.errorhandler(500)
def page_not_found(e):
return render_template('500.html'), 500
## App views
@app.route('/')
def index():
return render_template('index.html')
@app.route('/policy/')
def policy():
return render_template('policy.html')
@app.route('/apps/')
def apps():
return render_template('apps.html')
@app.route('/apps/<app_slug>')
def app_view(app_slug):
'''
App View
'''
# Check that directory exists
if not os.path.exists('templates/apps/%s/' % app_slug):
abort(404)
return render_template('apps/%s/index.html' % app_slug)
if __name__ == '__main__':
# Bind to PORT if defined, otherwise default to 5000.
port = int(os.environ.get('PORT', 5000))
if not os.environ.get('PORT'):
app.debug = True
app.run(host='0.0.0.0', port=port)