# HG changeset patch # User David Soria Parra # Date 1394237281 28800 # Node ID 20cfd68e9c49e62e237b7f1349d8b5ae66d0d16d # Parent 53ac7f3e5d4bd14ca0a7f90daeaf1c20b48c9611 Add hgwebsite wsgi handler diff -r 53ac7f3e5d4b -r 20cfd68e9c49 hgwebsite.py --- /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 +# +# 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('/') +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() diff -r 53ac7f3e5d4b -r 20cfd68e9c49 hgwebsite.wsgi --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hgwebsite.wsgi Fri Mar 07 16:08:01 2014 -0800 @@ -0,0 +1,1 @@ +from hgwebsite import app as application diff -r 53ac7f3e5d4b -r 20cfd68e9c49 run.py --- a/run.py Fri Mar 07 15:35:00 2014 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -# -# (c) 2014 David Soria Parra -# -# 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('/') -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) - - -app.debug = True -if __name__ == '__main__': - app.run()