-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
39 lines (33 loc) · 808 Bytes
/
main.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
from flask import Flask
from datetime import datetime
from influxdb import InfluxDBClient
client = InfluxDBClient('influxdb', 8086, 'admin', 'admin', 'metrics')
app = Flask(__name__)
@app.route("/hello")
def hello():
client.write_points([{
"measurement": "endpoint_request",
"tags": {
"endpoint": "/hello",
},
"time": datetime.now(),
"fields": {
"value": 1
}
}])
return "Hello World!"
@app.route("/bye")
def bye():
client.write_points([{
"measurement": "endpoint_request",
"tags": {
"endpoint": "/bye",
},
"time": datetime.now(),
"fields": {
"value": 1
}
}])
return "Bye World!"
if __name__ == "__main__":
app.run (host="0.0.0.0")