-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
executable file
·48 lines (37 loc) · 1.12 KB
/
app.py
File metadata and controls
executable file
·48 lines (37 loc) · 1.12 KB
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
from flask import Flask, json
import settings
from custom_logging import logging_message
app = Flask(__name__)
@app.route("/")
def hello():
app.logger.info("Main request successfull")
return "Hello World!"
@app.route("/healthcheck", endpoint="healthcheck")
@logging_message(app)
def healthcheck():
response = app.response_class(
response=json.dumps({"result": "OK - healthy"}),
status=200,
mimetype="application/json",
)
return response
# https://stackoverflow.com/questions/17256602/assertionerror-view-function-mapping-is-overwriting-an-existing-endpoint-functi
@app.route("/metrics", endpoint="metrics")
@logging_message(app)
def metrics():
response = app.response_class(
response=json.dumps(
{
"status": "success",
"code": 0,
"data": {"UserCount": 140, "UserCountActive": 23},
}
),
status=200,
mimetype="application/json",
)
return response
if __name__ == "__main__":
app.run(
host=settings.SERVER_HOST, port=settings.SERVER_PORT, debug=settings.FLASK_DEBUG
)