Spaces:
Runtime error
Runtime error
Commit
·
a861820
1
Parent(s):
84a501a
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, request, jsonify
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
app = Flask(__name__)
|
| 5 |
+
|
| 6 |
+
@app.route('/', defaults={'path': ''})
|
| 7 |
+
@app.route('/<path:path>', methods=['GET', 'POST'])
|
| 8 |
+
def proxy(path):
|
| 9 |
+
url = 'http://адрес_целевого_сервера/' + path
|
| 10 |
+
headers = {'Content-Type': 'application/json'}
|
| 11 |
+
response = requests.request(
|
| 12 |
+
method=request.method,
|
| 13 |
+
url=url,
|
| 14 |
+
headers=headers,
|
| 15 |
+
data=request.get_data(),
|
| 16 |
+
cookies=request.cookies,
|
| 17 |
+
stream=True,
|
| 18 |
+
)
|
| 19 |
+
return response.content, response.status_code, response.headers.items()
|
| 20 |
+
|
| 21 |
+
if __name__ == '__main__':
|
| 22 |
+
app.run()
|