Skip to content
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