-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
34 lines (26 loc) · 965 Bytes
/
main.py
File metadata and controls
34 lines (26 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import logging
from flask import Flask
from flask_talisman import Talisman
app = Flask(__name__)
Talisman(app, content_security_policy=None) # automatic redirection of http to https
import page_handler
logging.getLogger().setLevel(logging.INFO)
"""
example of handling POST methods
@app.route('/url-for-post', methods=['POST'])
def handleForPOSTMethod():
return some_handler.FooHandler()
"""
# <path:path> only captures non empty path, so we exceptionnaly need to add this additional route,
# but under the hood it's all the same.
@app.route('/')
def handleHome():
return page_handler.StaticPageHandler('/')
# handles all urls except '/'
@app.route('/<path:path>')
def handle(path):
return page_handler.StaticPageHandler('/' + path)
if __name__ == '__main__':
# This is used when running locally. Gunicorn is used to run the
# application on Google App Engine. See entrypoint in app.yaml.
app.run(host='127.0.0.1', port=8080, debug=True)