Spaces:
Running
Running
BraydenMoore
commited on
Commit
·
b94dcf8
1
Parent(s):
76e6304
Update main.py
Browse files
main.py
CHANGED
@@ -31,14 +31,20 @@ def latlon_to_pixel(loc):
|
|
31 |
x = ((longitude+180)/360)
|
32 |
return x*100, y*100
|
33 |
|
|
|
|
|
34 |
@app.route('/proxy/<path:url>')
|
35 |
def proxy(url):
|
36 |
-
|
|
|
|
|
|
|
37 |
headers = {'User-Agent': 'Mozilla/5.0'}
|
38 |
try:
|
39 |
-
req = requests.get(f'http://{
|
40 |
-
|
41 |
|
|
|
42 |
return Response(req.iter_content(chunk_size=10*1024), content_type=content_type)
|
43 |
|
44 |
except requests.exceptions.RequestException as e:
|
|
|
31 |
x = ((longitude+180)/360)
|
32 |
return x*100, y*100
|
33 |
|
34 |
+
from urllib.parse import urlparse, parse_qs
|
35 |
+
|
36 |
@app.route('/proxy/<path:url>')
|
37 |
def proxy(url):
|
38 |
+
|
39 |
+
parsed_url = urlparse(f'http://{url}')
|
40 |
+
query_params = parse_qs(parsed_url.query)
|
41 |
+
|
42 |
headers = {'User-Agent': 'Mozilla/5.0'}
|
43 |
try:
|
44 |
+
req = requests.get(f'http://{parsed_url.scheme}://{parsed_url.netloc}{parsed_url.path}',
|
45 |
+
params=query_params, headers=headers, stream=True, timeout=20)
|
46 |
|
47 |
+
content_type = req.headers['content-type']
|
48 |
return Response(req.iter_content(chunk_size=10*1024), content_type=content_type)
|
49 |
|
50 |
except requests.exceptions.RequestException as e:
|