-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
38 lines (31 loc) · 984 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
from flask import Flask
from flask import json
import logging
app = Flask(__name__)
@app.route('/status')
def healthcheck():
response = app.response_class(
response=json.dumps({"result":"OK - healthy"}),
status=200,
mimetype='application/json'
)
app.logger.info('Status request successfull')
app.logger.debug('DEBUG message')
return response
@app.route('/metrics')
def metrics():
response = app.response_class(
response=json.dumps({"status":"success","code":0,"data":{"UserCount":140,"UserCountActive":23}}),
status=200,
mimetype='application/json'
)
app.logger.info('Metrics request successfull')
return response
@app.route("/")
def hello():
app.logger.info('Main request successfull')
return "Hello World!"
if __name__ == "__main__":
## stream logs to a file
logging.basicConfig(filename='app.log',level=logging.DEBUG)
app.run(host='0.0.0.0')