THED2 commited on
Commit
e95661d
·
verified ·
1 Parent(s): 2bbca72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -153,12 +153,11 @@ async def download(task_id: str):
153
  if task_id not in tasks or tasks[task_id]["status"] != "completed":
154
  return {"error": "File not ready"}
155
 
156
- # Hugging Face reverse proxy buffering ko explicit bypass karne ke liye headers
157
  headers = {
158
  "X-Accel-Buffering": "no",
159
  "Cache-Control": "no-cache, no-store, must-revalidate",
160
- "Pragma": "no-cache",
161
- "Expires": "0"
162
  }
163
  return FileResponse(
164
  tasks[task_id]["file_path"],
@@ -175,10 +174,10 @@ async def stream(task_id: str, request: Request):
175
  file_size = os.path.getsize(file_path)
176
  range_header = request.headers.get("Range")
177
 
178
- # Fast output transfer ke liye chunk size 1MB se 4MB ke beech hona chahiye (Overhead kam karne ke liye)
179
  STREAM_CHUNK_SIZE = 2 * 1024 * 1024
180
 
181
- # Common performance headers jo proxy networks ko instantaneous routing ke liye force karte hain
182
  base_headers = {
183
  "X-Accel-Buffering": "no",
184
  "Cache-Control": "no-cache, no-store, must-revalidate",
 
153
  if task_id not in tasks or tasks[task_id]["status"] != "completed":
154
  return {"error": "File not ready"}
155
 
156
+ # Hugging Face reverse proxy buffer layer bypass headers
157
  headers = {
158
  "X-Accel-Buffering": "no",
159
  "Cache-Control": "no-cache, no-store, must-revalidate",
160
+ "Pragma": "no-cache"
 
161
  }
162
  return FileResponse(
163
  tasks[task_id]["file_path"],
 
174
  file_size = os.path.getsize(file_path)
175
  range_header = request.headers.get("Range")
176
 
177
+ # OUTPUT DATA PIPELINE UNLOCK: User download chunk size badhakar 2MB kar diya hai taaki throughput fast ho sake
178
  STREAM_CHUNK_SIZE = 2 * 1024 * 1024
179
 
180
+ # Proxy bypass headers to stop network-side buffering during transmission
181
  base_headers = {
182
  "X-Accel-Buffering": "no",
183
  "Cache-Control": "no-cache, no-store, must-revalidate",