Commit
·
6d4e93b
1
Parent(s):
1953589
Update main.py
Browse files
main.py
CHANGED
|
@@ -29,10 +29,16 @@ def latlon_to_pixel(loc):
|
|
| 29 |
|
| 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=15)
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
except requests.exceptions.RequestException as e:
|
| 37 |
print('error.')
|
| 38 |
return send_file('static/error.png', mimetype='image/png')
|
|
|
|
| 29 |
|
| 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=15)
|
| 35 |
+
content_type = req.headers['content-type']
|
| 36 |
+
|
| 37 |
+
if 'image' in content_type:
|
| 38 |
+
return send_file(req.raw, mimetype=content_type)
|
| 39 |
+
|
| 40 |
+
return Response(req.iter_content(chunk_size=10*1024), content_type=content_type)
|
| 41 |
+
|
| 42 |
except requests.exceptions.RequestException as e:
|
| 43 |
print('error.')
|
| 44 |
return send_file('static/error.png', mimetype='image/png')
|