Update app.py
Browse files
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
|
| 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 |
-
#
|
| 179 |
STREAM_CHUNK_SIZE = 2 * 1024 * 1024
|
| 180 |
|
| 181 |
-
#
|
| 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",
|