Spaces:
Running
Running
BraydenMoore
commited on
Commit
·
30aaad8
1
Parent(s):
0abe2d7
Update main.py
Browse files
main.py
CHANGED
@@ -30,15 +30,12 @@ def latlon_to_pixel(loc):
|
|
30 |
@app.route('/proxy/<path:url>')
|
31 |
def proxy(url):
|
32 |
print('URL:',url)
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
print('retrying...')
|
40 |
-
retries -= 1
|
41 |
-
return send_file('static/error.png', mimetype='image/png')
|
42 |
|
43 |
@app.route('/')
|
44 |
def index():
|
|
|
30 |
@app.route('/proxy/<path:url>')
|
31 |
def proxy(url):
|
32 |
print('URL:',url)
|
33 |
+
try:
|
34 |
+
req = requests.get(f'http://{url}', stream=True, timeout=5)
|
35 |
+
return Response(req.iter_content(chunk_size=10*1024), content_type=req.headers['content-type'])
|
36 |
+
except requests.exceptions.RequestException as e:
|
37 |
+
print('error.')
|
38 |
+
return send_file('static/error.png', mimetype='image/png')
|
|
|
|
|
|
|
39 |
|
40 |
@app.route('/')
|
41 |
def index():
|