Spaces:
Running
Running
Commit
·
1182110
1
Parent(s):
faf6209
Update main.py
Browse files
main.py
CHANGED
@@ -91,21 +91,16 @@ def proxy(url):
|
|
91 |
|
92 |
clean_url = full_url.replace('proxy/', '')
|
93 |
clean_url = encode_url(clean_url)
|
94 |
-
should_abort = lambda: 'abort' in session and session['abort']
|
95 |
-
|
96 |
-
def generate(should_abort):
|
97 |
-
for chunk in req.iter_content(chunk_size=1024):
|
98 |
-
if should_abort():
|
99 |
-
break
|
100 |
-
yield chunk
|
101 |
|
102 |
try:
|
103 |
-
start = time.time()
|
104 |
-
|
105 |
-
logging.info(f"Sending request to: {clean_url}")
|
106 |
req = requests.get(clean_url, headers=headers, stream=True, timeout=2)
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
-
return Response(
|
109 |
|
110 |
except Exception as e:
|
111 |
logging.error(f"Error in proxy: {str(e)}")
|
|
|
91 |
|
92 |
clean_url = full_url.replace('proxy/', '')
|
93 |
clean_url = encode_url(clean_url)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
try:
|
|
|
|
|
|
|
96 |
req = requests.get(clean_url, headers=headers, stream=True, timeout=2)
|
97 |
+
logging.info(f"TIME: {time.time()-start}, Status Code: {req.status_code}, Response Headers: {req.headers}")
|
98 |
+
|
99 |
+
end_time = time.time()
|
100 |
+
elapsed_time = end_time - start_time
|
101 |
+
print(f"\nTime taken for proxy: {elapsed_time} seconds\n")
|
102 |
|
103 |
+
return Response(req.iter_content(chunk_size=1024), content_type=req.headers['content-type'])
|
104 |
|
105 |
except Exception as e:
|
106 |
logging.error(f"Error in proxy: {str(e)}")
|