-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
58 lines (39 loc) · 996 Bytes
/
app.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
54
55
56
57
58
import time
import random
import os
from flask import Flask
from prometheus_flask_exporter import PrometheusMetrics
app = Flask(__name__)
PrometheusMetrics(app)
endpoints = ("one", "two", "three", "four", "five", "error")
@app.route("/color")
def tell_color():
try:
return os.environ.get("COLOR")
except (RuntimeError, TypeError, NameError):
print("Error")
return ":(", 500
# except (Exception, ex):
# print(ex)
# return ":(", 500
@app.route("/one")
def first_route():
time.sleep(random.random() * 0.2)
return "ok"
@app.route("/two")
def the_second():
time.sleep(random.random() * 0.4)
return "ok"
@app.route("/three")
def test_3rd():
time.sleep(random.random() * 0.6)
return "ok"
@app.route("/four")
def fourth_one():
time.sleep(random.random() * 0.8)
return "ok"
@app.route("/error")
def oops():
return ":(", 500
if __name__ == "__main__":
app.run("0.0.0.0", 5000, threaded=True)