comparison hgwebsite.py @ 405:4dfad479ee98

Properly serve static files in static/$FILE directly
author David Soria Parra <davidsp@fb.com>
date Tue, 11 Mar 2014 15:17:05 -0700
parents 4d4c4b73808e
children 8e93934dc587
comparison
equal deleted inserted replaced
404:ba56a7021f6d 405:4dfad479ee98
18 def about(site=None): 18 def about(site=None):
19 if not site: 19 if not site:
20 flask.abort(404) 20 flask.abort(404)
21 root = os.path.dirname(os.path.abspath(__file__)) 21 root = os.path.dirname(os.path.abspath(__file__))
22 tpath = os.path.join(root, 'templates', site, 'index.html') 22 tpath = os.path.join(root, 'templates', site, 'index.html')
23 if not os.path.exists(tpath): 23 if os.path.exists(tpath):
24 flask.abort(404) 24 t = os.path.join(site, 'index.html')
25 t = os.path.join(site, 'index.html') 25 return flask.render_template(t)
26 return flask.render_template(t) 26 spath = os.path.join(root, 'static', site)
27 if os.path.exists(spath):
28 return app.send_static_file(site)
29 flask.abort(404)
27 30
28 31
29 if os.getenv("HGWEBSITE_DEBUG", None): 32 if os.getenv("HGWEBSITE_DEBUG", None):
30 app.debug = True 33 app.debug = True
31 34