diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgwebsite.py	Fri Mar 07 16:08:01 2014 -0800
@@ -0,0 +1,32 @@
+#
+# (c) 2014 David Soria Parra <dsp@php.net>
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+import os
+import flask
+
+app = flask.Flask(__name__)
+
+
+@app.route('/')
+def indexpage():
+    return flask.render_template('frontpage.html')
+
+
+@app.route('/<site>')
+def about(site=None):
+    if not site:
+        flask.abort(404)
+    tpath = os.path.join('templates', site, 'index.html')
+    if not os.path.exists(tpath):
+        flask.abort(404)
+    t = os.path.join(site, 'index.html')
+    return flask.render_template(t)
+
+
+if os.getenv("HGWEBSITE_DEBUG", None):
+    app.debug = True
+
+if __name__ == '__main__':
+    app.run()