Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, request, Response, jsonify
|
2 |
+
import logging
|
3 |
+
|
4 |
+
app = Flask(__name__)
|
5 |
+
logging.basicConfig(level=logging.INFO)
|
6 |
+
|
7 |
+
@app.route('/')
|
8 |
+
def show_ip():
|
9 |
+
client_ip = request.headers.get('X-Forwarded-For', request.remote_addr)
|
10 |
+
logging.info(f"Zugriff von IP: {client_ip}")
|
11 |
+
return jsonify({
|
12 |
+
"your_ip": client_ip,
|
13 |
+
"proxy_config_url": request.url_root + "proxy.pac"
|
14 |
+
})
|
15 |
+
|
16 |
+
@app.route('/proxy.pac')
|
17 |
+
def proxy_pac():
|
18 |
+
pac_content = """function FindProxyForURL(url, host) {
|
19 |
+
return "PROXY %s:7860; DIRECT";
|
20 |
+
}""" % request.host
|
21 |
+
|
22 |
+
return Response(
|
23 |
+
pac_content,
|
24 |
+
mimetype='application/x-ns-proxy-autoconfig'
|
25 |
+
)
|
26 |
+
|
27 |
+
if __name__ == "__main__":
|
28 |
+
app.run(host="0.0.0.0", port=7860)
|