Mercurial > hg-website
changeset 400:20cfd68e9c49
Add hgwebsite wsgi handler
author | David Soria Parra <davidsp@fb.com> |
---|---|
date | Fri, 07 Mar 2014 16:08:01 -0800 |
parents | 53ac7f3e5d4b |
children | 4d4c4b73808e |
files | hgwebsite.py hgwebsite.wsgi run.py |
diffstat | 3 files changed, 33 insertions(+), 30 deletions(-) [+] |
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()
--- /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
--- 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 <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) - - -app.debug = True -if __name__ == '__main__': - app.run()