DanilNikolin commited on
Commit
1e58f35
·
verified ·
1 Parent(s): bcf1316

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -21
app.py CHANGED
@@ -1,7 +1,10 @@
 
1
  from flask import Flask, request, jsonify
 
2
  import requests
3
 
4
  app = Flask(__name__)
 
5
 
6
  @app.route('/proxy', methods=['POST'])
7
  def proxy():
@@ -9,26 +12,9 @@ def proxy():
9
  headers = request.json.get('headers')
10
  data = request.json.get('data')
11
 
12
- print(f"URL: {url}")
13
- print(f"Headers: {headers}")
14
- print(f"Data: {data}")
15
-
16
- try:
17
- response = requests.post(url, headers=headers, json=data)
18
- response.raise_for_status()
19
- return jsonify(response.json())
20
- except requests.exceptions.HTTPError as errh:
21
- print ("Http Error:", errh)
22
- return jsonify({"error": "HTTP error occurred", "details": str(errh)}), 500
23
- except requests.exceptions.ConnectionError as errc:
24
- print ("Error Connecting:", errc)
25
- return jsonify({"error": "Connection error occurred", "details": str(errc)}), 500
26
- except requests.exceptions.Timeout as errt:
27
- print ("Timeout Error:", errt)
28
- return jsonify({"error": "Timeout error occurred", "details": str(errt)}), 500
29
- except requests.exceptions.RequestException as err:
30
- print ("OOps: Something Else", err)
31
- return jsonify({"error": "An error occurred", "details": str(err)}), 500
32
 
33
  if __name__ == '__main__':
34
- app.run(host='0.0.0.0', port=5000)
 
1
+ # app.py
2
  from flask import Flask, request, jsonify
3
+ from flask_cors import CORS
4
  import requests
5
 
6
  app = Flask(__name__)
7
+ CORS(app) # Добавление CORS
8
 
9
  @app.route('/proxy', methods=['POST'])
10
  def proxy():
 
12
  headers = request.json.get('headers')
13
  data = request.json.get('data')
14
 
15
+ response = requests.post(url, headers=headers, json=data)
16
+
17
+ return jsonify(response.json())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  if __name__ == '__main__':
20
+ app.run(host='0.0.0.0', port=5000)