Spaces:
Running
Running
BraydenMoore
commited on
Commit
·
ed440ee
1
Parent(s):
1bfeee2
Update main.py
Browse files
main.py
CHANGED
@@ -8,6 +8,7 @@ import pytz
|
|
8 |
from io import BytesIO
|
9 |
import logging
|
10 |
import os
|
|
|
11 |
|
12 |
logging.basicConfig(level=logging.INFO)
|
13 |
|
@@ -81,16 +82,17 @@ def proxy(url):
|
|
81 |
clean_url = url.replace('proxy/', '')
|
82 |
|
83 |
try:
|
|
|
|
|
84 |
logging.info(f"Sending request to: {clean_url}")
|
85 |
-
req = requests.get(clean_url, headers=headers, stream=True, timeout=
|
86 |
-
logging.info(f"Status Code: {req.status_code}, Response Headers: {req.headers}")
|
87 |
return Response(req.iter_content(chunk_size=2048), content_type=req.headers['content-type'])
|
88 |
|
89 |
except Exception as e:
|
90 |
logging.error(f"Error in proxy: {str(e)}")
|
91 |
print('Skipped')
|
92 |
return redirect(url_for('index', new='true'))
|
93 |
-
#return send_file('static/error.png', mimetype='image/png')
|
94 |
|
95 |
|
96 |
@app.route('/')
|
|
|
8 |
from io import BytesIO
|
9 |
import logging
|
10 |
import os
|
11 |
+
import time
|
12 |
|
13 |
logging.basicConfig(level=logging.INFO)
|
14 |
|
|
|
82 |
clean_url = url.replace('proxy/', '')
|
83 |
|
84 |
try:
|
85 |
+
import time
|
86 |
+
start = time.time()
|
87 |
logging.info(f"Sending request to: {clean_url}")
|
88 |
+
req = requests.get(clean_url, headers=headers, stream=True, timeout=1)
|
89 |
+
logging.info(f"TIME: {time.time()-start}, Status Code: {req.status_code}, Response Headers: {req.headers}")
|
90 |
return Response(req.iter_content(chunk_size=2048), content_type=req.headers['content-type'])
|
91 |
|
92 |
except Exception as e:
|
93 |
logging.error(f"Error in proxy: {str(e)}")
|
94 |
print('Skipped')
|
95 |
return redirect(url_for('index', new='true'))
|
|
|
96 |
|
97 |
|
98 |
@app.route('/')
|