Update app.py
Browse files
app.py
CHANGED
@@ -6,38 +6,38 @@ app.logger.disabled = True
|
|
6 |
|
7 |
@app.route('/')
|
8 |
def show_ip():
|
9 |
-
return jsonify({
|
10 |
-
"status": "running",
|
11 |
-
"proxy_config_url": request.url_root + "proxy.pac"
|
12 |
-
})
|
13 |
|
14 |
@app.route('/proxy.pac')
|
15 |
def proxy_pac():
|
16 |
-
pac_content = """function FindProxyForURL(url, host) {
|
17 |
-
return "PROXY %s:7860; DIRECT";
|
18 |
-
}""" % request.host
|
19 |
|
20 |
-
return Response(
|
21 |
-
pac_content,
|
22 |
-
mimetype='application/x-ns-proxy-autoconfig'
|
23 |
-
)
|
24 |
|
25 |
@app.route('/<path:url>', methods=['GET', 'POST', 'PUT', 'DELETE'])
|
26 |
def proxy(url):
|
27 |
-
try:
|
28 |
-
response = requests.request(
|
29 |
-
method=request.method,
|
30 |
-
url=url,
|
31 |
-
headers={key: value for (key, value) in request.headers if key != 'Host'},
|
32 |
-
data=request.get_data(),
|
33 |
-
allow_redirects=False
|
34 |
-
)
|
35 |
-
return Response(response.content, response.status_code)
|
36 |
-
except:
|
37 |
-
return Response("Error", 500)
|
38 |
|
39 |
if __name__ == "__main__":
|
40 |
-
import logging
|
41 |
-
log = logging.getLogger('werkzeug')
|
42 |
-
log.disabled = True
|
43 |
-
app.run(host="0.0.0.0", port=7860)
|
|
|
6 |
|
7 |
@app.route('/')
|
8 |
def show_ip():
|
9 |
+
return jsonify({
|
10 |
+
"status": "running",
|
11 |
+
"proxy_config_url": request.url_root + "proxy.pac"
|
12 |
+
})
|
13 |
|
14 |
@app.route('/proxy.pac')
|
15 |
def proxy_pac():
|
16 |
+
pac_content = """function FindProxyForURL(url, host) {
|
17 |
+
return "PROXY %s:7860; DIRECT";
|
18 |
+
}""" % request.host
|
19 |
|
20 |
+
return Response(
|
21 |
+
pac_content,
|
22 |
+
mimetype='application/x-ns-proxy-autoconfig'
|
23 |
+
)
|
24 |
|
25 |
@app.route('/<path:url>', methods=['GET', 'POST', 'PUT', 'DELETE'])
|
26 |
def proxy(url):
|
27 |
+
try:
|
28 |
+
response = requests.request(
|
29 |
+
method=request.method,
|
30 |
+
url=url,
|
31 |
+
headers={key: value for (key, value) in request.headers if key != 'Host'},
|
32 |
+
data=request.get_data(),
|
33 |
+
allow_redirects=False
|
34 |
+
)
|
35 |
+
return Response(response.content, response.status_code)
|
36 |
+
except:
|
37 |
+
return Response("Error", 500)
|
38 |
|
39 |
if __name__ == "__main__":
|
40 |
+
import logging
|
41 |
+
log = logging.getLogger('werkzeug')
|
42 |
+
log.disabled = True
|
43 |
+
app.run(host="0.0.0.0", port=7860)
|