Athspi commited on
Commit
ddafe1f
·
verified ·
1 Parent(s): 4662631

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, render_template, request
2
+ import requests
3
+
4
+ app = Flask(__name__)
5
+
6
+ # SOCKS5 proxy (VPN-like endpoint) configuration
7
+ # Replace with your VPN-provided SOCKS5 proxy IP and port
8
+ socks5_proxy_host = '127.0.0.1' # Example: '127.0.0.1' if local VPN tunnel or SSH tunnel
9
+ socks5_proxy_port = 1080 # Example: 1080 (OpenVPN or SSH dynamic port forwarding)
10
+
11
+ proxies = {
12
+ 'http': f'socks5h://{socks5_proxy_host}:{socks5_proxy_port}',
13
+ 'https': f'socks5h://{socks5_proxy_host}:{socks5_proxy_port}',
14
+ }
15
+
16
+ @app.route('/', methods=['GET', 'POST'])
17
+ def home():
18
+ url = ''
19
+ page_content = ''
20
+ error = ''
21
+
22
+ if request.method == 'POST':
23
+ url = request.form.get('url')
24
+ if not url.startswith(('http://', 'https://')):
25
+ url = 'http://' + url
26
+
27
+ try:
28
+ # Fetch the page via SOCKS5 proxy
29
+ response = requests.get(url, proxies=proxies, timeout=10)
30
+ response.raise_for_status()
31
+ page_content = response.text
32
+ except Exception as e:
33
+ error = str(e)
34
+
35
+ return render_template('index.html', url=url, page_content=page_content, error=error)
36
+
37
+ if __name__ == '__main__':
38
+ app.run(debug=True)