BraydenMoore commited on
Commit
e3df782
·
1 Parent(s): 5febe94

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -5
main.py CHANGED
@@ -29,11 +29,15 @@ def latlon_to_pixel(loc):
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 send_file('static/error.png', mimetype='image/png')
 
 
 
 
37
 
38
  @app.route('/')
39
  def index():
 
29
 
30
  @app.route('/proxy/<path:url>')
31
  def proxy(url):
32
+ retries = 3
33
+ while retries > 0:
34
+ try:
35
+ req = requests.get(f'http://{url}', stream=True, timeout=10)
36
+ return Response(req.iter_content(chunk_size=10*1024), content_type=req.headers['content-type'])
37
+ except requests.exceptions.RequestException as e:
38
+ retries -= 1
39
+ time.sleep(1)
40
+ return send_file('static/error.png', mimetype='image/png')
41
 
42
  @app.route('/')
43
  def index():