- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
Latest commit
34 lines (26 loc) · 965 Bytes
/
Copy pathmain.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
importlogging
fromflaskimportFlask
fromflask_talismanimportTalisman
app=Flask(__name__)
Talisman(app, content_security_policy=None) # automatic redirection of http to https
importpage_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('/')
defhandleHome():
returnpage_handler.StaticPageHandler('/')
# handles all urls except '/'
@app.route('/<path:path>')
defhandle(path):
returnpage_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)