-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
43 lines (33 loc) · 1002 Bytes
/
app.py
File metadata and controls
43 lines (33 loc) · 1002 Bytes
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
import sys, os
sys.path.append(os.path.dirname(__file__))
from bottle import run, request, response, route, abort,default_app, static_file, mako_template, debug, redirect
import json, functools
from ast import literal_eval
try:
PRODUCTION = bool(os.environ['PRODUCTION'])
except:
PRODUCTION = False
if PRODUCTION :
STATIC_PATH = '/your/absoulte/production/path/to/folder/static'
else:
STATIC_PATH = './static'
if not PRODUCTION:
debug(True)
app = application = default_app()
@route('/static/<filename:path>')
def send_file(filename):
return static_file(filename,root=STATIC_PATH)
@route('/')
@route('/<page>')
def index(page = None):
if not page:
return mako_template('index.html')
else:
tpl = page + '.html'
try:
#return mako_template(tpl,user)
return mako_template(tpl)
except:
return '<h1>Page not found</h1>'
if __name__ == '__main__':
run(app,host='0.0.0.0',port=8000,reloader=True)