Spaces:
Running
Running
Commit
·
9033931
1
Parent(s):
6c5ca18
Update main.py
Browse files
main.py
CHANGED
@@ -29,11 +29,11 @@ def latlon_to_pixel(loc):
|
|
29 |
|
30 |
@app.route('/proxy/<path:url>')
|
31 |
def proxy(url):
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
|
38 |
@app.route('/')
|
39 |
def index():
|
|
|
29 |
|
30 |
@app.route('/proxy/<path:url>')
|
31 |
def proxy(url):
|
32 |
+
try:
|
33 |
+
req = requests.get(f'http://{url}', stream=True, timeout=10)
|
34 |
+
return Response(req.iter_content(chunk_size=10*1024), content_type=req.headers['content-type'])
|
35 |
+
except requests.exceptions.RequestException as e:
|
36 |
+
return f"An error occurred: {e}", 500
|
37 |
|
38 |
@app.route('/')
|
39 |
def index():
|