BraydenMoore commited on
Commit
f335a66
1 Parent(s): 65976ca

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -8
main.py CHANGED
@@ -54,14 +54,15 @@ def proxy(url):
54
  clean_url = url.replace('proxy/', '')
55
  print('Cleaned URL:', clean_url)
56
 
57
- req = requests.get(f'{clean_url}', headers=headers, stream=True, timeout=10)
58
- print("Status Code:", req.status_code)
59
- print("Response Headers:", req.headers)
60
-
61
- content_type = req.headers['content-type']
62
-
63
- return Response(req.iter_content(chunk_size=512), content_type=content_type)
64
-
 
65
  except:
66
  print(f'Redirecting')
67
  return send_file('static/error.png', mimetype='image/png')
 
54
  clean_url = url.replace('proxy/', '')
55
  print('Cleaned URL:', clean_url)
56
 
57
+ if '.jpg' in clean_url:
58
+ req = requests.get(f'{clean_url}', headers=headers, timeout=3)
59
+ content_type = req.headers['content-type']
60
+ return Response(req.content, content_type=content_type)
61
+ else:
62
+ req = requests.get(f'{clean_url}', headers=headers, stream=True, timeout=10)
63
+ content_type = req.headers['content-type']
64
+ return Response(req.iter_content(chunk_size=512), content_type=content_type)
65
+
66
  except:
67
  print(f'Redirecting')
68
  return send_file('static/error.png', mimetype='image/png')