-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.py
More file actions
40 lines (29 loc) · 895 Bytes
/
app.py
File metadata and controls
40 lines (29 loc) · 895 Bytes
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
39
40
from pprint import pprint
from textwrap import wrap
from flask import Flask, jsonify, request
app = Flask(__name__)
methods = ["GET", "POST", "PATCH", "DELETE"]
@app.route("/", methods=methods, defaults={"path": ""})
@app.route("/<path:path>", methods=methods)
def hello_world(path):
divider = "================================================================"
j = request.get_json()
print(divider)
print(f"*** Received data at: {path}")
print("\n** data:")
print("\n".join(wrap(request.data.decode())))
print("\n** form:")
pprint(request.form)
print("\n** json:")
pprint(j)
print(f"{divider}\n\n")
return jsonify(
{
"endpoint": path,
"data": request.data.decode("utf-8"),
"form": request.form,
"json": request.get_json(),
}
)
if __name__ == "__main__":
app.run()