Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added metrics and status new #92

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions exercises/python-helloworld/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
from email.mime import application
import json
import mimetypes
from urllib import response
from flask import Flask
app = Flask(__name__)



@app.route('/status')
def status():
response = app.response_class(
response=json.dumps({"result":"OK - healthy"}), #json.dumps() converts python object it a json string
status=200, #this refers to the http requests has been succesfully served
mimetype='application/json' #format of the response data
)

return response


@app.route('/metrics')
def metrics():
response = app.response_class(
response=json.dumps({"status":"success","code":0,"data":{"UserCount": 140, "UserCountActive": 23}}), #json.dumps() converts python object it a json string
status=200, #this refers to the http requests has been succesfully served
mimetype='application/json' #format of the response data
)

return response

@app.route("/")
def hello():
return "Hello World!"
Expand Down