from flask import Flask, request, Response, jsonify | |
app = Flask(__name__) | |
# Logging komplett deaktivieren | |
app.logger.disabled = True | |
def show_ip(): | |
# Minimale Antwort ohne Logging | |
return jsonify({ | |
"status": "running", | |
"proxy_config_url": request.url_root + "proxy.pac" | |
}) | |
def proxy_pac(): | |
pac_content = """function FindProxyForURL(url, host) { | |
return "PROXY %s:7860; DIRECT"; | |
}""" % request.host | |
return Response( | |
pac_content, | |
mimetype='application/x-ns-proxy-autoconfig' | |
) | |
def proxy(url): | |
try: | |
response = requests.request( | |
method=request.method, | |
url=url, | |
headers={key: value for (key, value) in request.headers if key != 'Host'}, | |
data=request.get_data(), | |
allow_redirects=False | |
) | |
return Response(response.content, response.status_code) | |
except: | |
return Response("Error", 500) | |
if __name__ == "__main__": | |
# Werkzeug Logger auch deaktivieren | |
import logging | |
log = logging.getLogger('werkzeug') | |
log.disabled = True | |
app.run(host="0.0.0.0", port=7860) |