forked from AWS-Devops-Projects/python-backend-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.py
31 lines (21 loc) · 730 Bytes
/
web.py
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
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
from flask import Flask, flash, redirect, render_template, request, session, abort
from random import randint
def shutdown_server():
func = request.environ.get('werkzeug.server.shutdown')
if func is None:
raise RuntimeError('Not running with the Werkzeug Server')
func()
myapp = Flask(__name__)
@myapp.route('/shutdown', methods=['POST'])
def shutdown():
shutdown_server()
return 'Server shutting down...'
@myapp.route("/")
def hello():
# return name
return render_template(
'test.html', **locals())
if __name__ == "__main__":
myapp.run(host='0.0.0.0', port=80)