Fixed /log view responses
This commit is contained in:
parent
20c38c5e1b
commit
25ed8eb24c
12
app.py
12
app.py
|
@ -19,14 +19,14 @@ def root_view():
|
||||||
filter(None, app.view_functions[rule.endpoint].__doc__.split("\n"))
|
filter(None, app.view_functions[rule.endpoint].__doc__.split("\n"))
|
||||||
)[0].strip()
|
)[0].strip()
|
||||||
|
|
||||||
# JSON response
|
|
||||||
if request.accept_mimetypes.accept_json:
|
|
||||||
return jsonify(routes)
|
|
||||||
|
|
||||||
# HTML response
|
# HTML response
|
||||||
if request.accept_mimetypes.accept_html:
|
if request.accept_mimetypes.accept_html:
|
||||||
return render_template("index.j2", routes=routes)
|
return render_template("index.j2", routes=routes)
|
||||||
|
|
||||||
|
# JSON response
|
||||||
|
if request.accept_mimetypes.accept_json:
|
||||||
|
return jsonify(routes)
|
||||||
|
|
||||||
# Plain text response
|
# Plain text response
|
||||||
return Response(
|
return Response(
|
||||||
"\n".join(
|
"\n".join(
|
||||||
|
@ -86,13 +86,15 @@ def log_view():
|
||||||
Accepts JSON and plain text
|
Accepts JSON and plain text
|
||||||
Returns the provided data on response
|
Returns the provided data on response
|
||||||
"""
|
"""
|
||||||
|
# JSON response
|
||||||
if request.is_json:
|
if request.is_json:
|
||||||
app.logger.warn(request.json)
|
app.logger.warn(request.json)
|
||||||
return jsonify(request.json)
|
return jsonify(request.json)
|
||||||
|
|
||||||
|
# Plain text response
|
||||||
data = request.get_data().decode("utf-8")
|
data = request.get_data().decode("utf-8")
|
||||||
app.logger.warn(data)
|
app.logger.warn(data)
|
||||||
return Response(data)
|
return Response(data, content_type="plain/text")
|
||||||
|
|
||||||
|
|
||||||
@app.route("/http_request", methods=["POST"])
|
@app.route("/http_request", methods=["POST"])
|
||||||
|
|
Loading…
Reference in New Issue