-
Notifications
You must be signed in to change notification settings - Fork 3
/
hello.py
53 lines (42 loc) · 1.13 KB
/
hello.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from __future__ import print_function
import os
import uuid
from flask import Flask, render_template
from cfenv import AppEnv
import time
from pprint import pformat
env = AppEnv()
app = Flask(__name__)
start = time.time()
from flask import request
def shutdown_server():
func = request.environ.get('werkzeug.server.shutdown')
if func is None:
raise RuntimeError('Not running with the Werkzeug Server')
func()
@app.route('/')
def hello():
now = time.time()
uptime = now-start
m, s = divmod(uptime, 60)
uptime = "%02dm%02ds" % (m, s)
return render_template("index.html",index=env.index,uptime=uptime)
@app.route('/exit')
def exit():
now = time.time()
uptime = now-start
m, s = divmod(uptime, 60)
uptime = "%02dm%02ds" % (m, s)
shutdown_server()
return render_template("exit.html",index=env.index,uptime=uptime)
@app.route('/env')
def showenv():
return render_template("env.html",env=os.environ)
@app.route('/port')
def port():
return env.port
@app.route('/index')
def index():
return env.index
if __name__ == "__main__":
app.run(debug=False,host='0.0.0.0',port=env.port)