-
Notifications
You must be signed in to change notification settings - Fork 6
/
celonis_proxy.py
45 lines (36 loc) · 1.42 KB
/
celonis_proxy.py
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
41
42
43
44
45
import requests
from flask import Flask, request
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
@app.route('/getWrapper', methods=['GET'])
def get_wrapper():
return requests.get(request.args["url"], headers={"Authorization": "Bearer " + request.args["access_token"]}).text
@app.route('/postWrapper', methods=['POST'])
def post_wrapper():
call_contents = request.get_json()
url = call_contents["url"]
access_token = call_contents["access_token"]
files = {}
if "files" in call_contents:
content = call_contents["files"]
content = content.encode("utf-8")
del call_contents["files"]
files["file"] = content
if "@@content" in call_contents:
call_contents = call_contents["@@content"]
return requests.post(url, headers={"Authorization": "Bearer " + access_token},
files=files, json=call_contents).text
@app.route('/putWrapper', methods=['POST'])
def put_wrapper():
call_contents = request.get_json()
url = call_contents["url"]
access_token = call_contents["access_token"]
return requests.put(url, headers={"Authorization": "Bearer " + access_token},
json=call_contents).text
USE_SSL = False
if __name__ == "__main__":
if USE_SSL:
app.run(threaded=True, port=5004, host="0.0.0.0", ssl_context=('local.crt', 'local.key'))
else:
app.run(threaded=True, port=5004, host="0.0.0.0")