-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (26 loc) · 860 Bytes
/
Copy pathmain.py
File metadata and controls
38 lines (26 loc) · 860 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
from flask import Flask
from flask import request,jsonify,Response
import json
import logging
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)
app = Flask(__name__)
def get_json(headers,method,path,body):
d={
"path" : path,
"headers" : {},
"method" : method,
"body" : body.decode("UTF8")
}
for i in headers:
key, val = i
d["headers"][key]=val
resp = json.dumps(d)
print(resp)
return resp
@app.route('/', defaults={'path': ''},methods=["POST","GET","OPTIONS","PUT","DELETE"])
@app.route('/<path:path>',methods=["POST","GET","OPTIONS","PUT","DELETE"])
def catch_all(path):
return Response(get_json(request.headers,request.method,request.full_path,request.data),mimetype='application/json')
if __name__ == '__main__':
app.run(host='0.0.0.0',port=5000)