Mercurial > hg-website
annotate hgwebsite.py @ 406:c5efd57859d6
Add more symlinks that are used by matt's build system
author | David Soria Parra <davidsp@fb.com> |
---|---|
date | Tue, 11 Mar 2014 15:29:20 -0700 |
parents | 4dfad479ee98 |
children | 8e93934dc587 |
rev | line source |
---|---|
400 | 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) | |
401 | 21 root = os.path.dirname(os.path.abspath(__file__)) |
22 tpath = os.path.join(root, 'templates', site, 'index.html') | |
405
4dfad479ee98
Properly serve static files in static/$FILE directly
David Soria Parra <davidsp@fb.com>
parents:
401
diff
changeset
|
23 if os.path.exists(tpath): |
4dfad479ee98
Properly serve static files in static/$FILE directly
David Soria Parra <davidsp@fb.com>
parents:
401
diff
changeset
|
24 t = os.path.join(site, 'index.html') |
4dfad479ee98
Properly serve static files in static/$FILE directly
David Soria Parra <davidsp@fb.com>
parents:
401
diff
changeset
|
25 return flask.render_template(t) |
4dfad479ee98
Properly serve static files in static/$FILE directly
David Soria Parra <davidsp@fb.com>
parents:
401
diff
changeset
|
26 spath = os.path.join(root, 'static', site) |
4dfad479ee98
Properly serve static files in static/$FILE directly
David Soria Parra <davidsp@fb.com>
parents:
401
diff
changeset
|
27 if os.path.exists(spath): |
4dfad479ee98
Properly serve static files in static/$FILE directly
David Soria Parra <davidsp@fb.com>
parents:
401
diff
changeset
|
28 return app.send_static_file(site) |
4dfad479ee98
Properly serve static files in static/$FILE directly
David Soria Parra <davidsp@fb.com>
parents:
401
diff
changeset
|
29 flask.abort(404) |
400 | 30 |
31 | |
32 if os.getenv("HGWEBSITE_DEBUG", None): | |
33 app.debug = True | |
34 | |
35 if __name__ == '__main__': | |
36 app.run() |