comparison hgwebsite.py @ 400:20cfd68e9c49

Add hgwebsite wsgi handler
author David Soria Parra <davidsp@fb.com>
date Fri, 07 Mar 2014 16:08:01 -0800
parents
children 4d4c4b73808e
comparison
equal deleted inserted replaced
399:53ac7f3e5d4b 400:20cfd68e9c49
1 #
2 # (c) 2014 David Soria Parra <dsp@php.net>
3 #
4 # This software may be used and distributed according to the terms of the
5 # GNU General Public License version 2 or any later version.
6 import os
7 import flask
8
9 app = flask.Flask(__name__)
10
11
12 @app.route('/')
13 def indexpage():
14 return flask.render_template('frontpage.html')
15
16
17 @app.route('/<site>')
18 def about(site=None):
19 if not site:
20 flask.abort(404)
21 tpath = os.path.join('templates', site, 'index.html')
22 if not os.path.exists(tpath):
23 flask.abort(404)
24 t = os.path.join(site, 'index.html')
25 return flask.render_template(t)
26
27
28 if os.getenv("HGWEBSITE_DEBUG", None):
29 app.debug = True
30
31 if __name__ == '__main__':
32 app.run()