Added log route

This commit is contained in:
Felipe Martin 2020-03-11 10:19:06 +01:00
parent 8e5ed54d5f
commit a6a44adda2
Signed by: fmartingr
GPG Key ID: 716BC147715E716F
1 changed files with 16 additions and 0 deletions

16
app.py
View File

@ -66,5 +66,21 @@ def headers():
)
@app.route("/log", methods=["POST"])
def view_log():
"""
Logs the provided payload into stdout.
Accepts JSON and plain text
Returns the provided data on response
"""
if request.is_json:
app.logger.warn(request.json)
return jsonify(request.json)
data = request.get_data().decode("utf-8")
app.logger.warn(data)
return Response(data)
if __name__ == "__main__":
app.run(debug=True, port=8080, host="0.0.0.0")