File size: 1,263 Bytes
8bfe2f6
11eb08a
 
8bfe2f6
11eb08a
8bfe2f6
 
 
 
 
11eb08a
ff5635d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11eb08a
8bfe2f6
ff5635d
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
from flask import Flask, request, jsonify
import requests

app = Flask(__name__)

@app.route('/proxy', methods=['POST'])
def proxy():
    url = request.json.get('url')
    headers = request.json.get('headers')
    data = request.json.get('data')

    print(f"URL: {url}")
    print(f"Headers: {headers}")
    print(f"Data: {data}")

    try:
        response = requests.post(url, headers=headers, json=data)
        response.raise_for_status()
        return jsonify(response.json())
    except requests.exceptions.HTTPError as errh:
        print ("Http Error:", errh)
        return jsonify({"error": "HTTP error occurred", "details": str(errh)}), 500
    except requests.exceptions.ConnectionError as errc:
        print ("Error Connecting:", errc)
        return jsonify({"error": "Connection error occurred", "details": str(errc)}), 500
    except requests.exceptions.Timeout as errt:
        print ("Timeout Error:", errt)
        return jsonify({"error": "Timeout error occurred", "details": str(errt)}), 500
    except requests.exceptions.RequestException as err:
        print ("OOps: Something Else", err)
        return jsonify({"error": "An error occurred", "details": str(err)}), 500

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000)