Update app.py
Browse files
app.py
CHANGED
|
@@ -29,6 +29,7 @@ from fastapi.staticfiles import StaticFiles
|
|
| 29 |
from collections import defaultdict
|
| 30 |
from starlette.responses import JSONResponse
|
| 31 |
import logging
|
|
|
|
| 32 |
|
| 33 |
tmp_dir = tempfile.gettempdir()
|
| 34 |
BASE_URL = "https://chrunos-multi.hf.space"
|
|
@@ -219,6 +220,8 @@ async def download_high_quality_video(request: Request):
|
|
| 219 |
# Increment the user's request count
|
| 220 |
user_info["count"] += 1
|
| 221 |
|
|
|
|
|
|
|
| 222 |
return {"url": download_url}
|
| 223 |
|
| 224 |
|
|
@@ -275,6 +278,7 @@ async def download_high_quality_video(request: Request):
|
|
| 275 |
downloaded_file = downloaded_files[0]
|
| 276 |
encoded_filename = urllib.parse.quote(downloaded_file.name)
|
| 277 |
download_url = f"{BASE_URL}/file/{encoded_filename}"
|
|
|
|
| 278 |
return {"url": download_url}
|
| 279 |
|
| 280 |
|
|
@@ -312,6 +316,7 @@ async def download_audio(request: Request):
|
|
| 312 |
downloaded_file = downloaded_files[0]
|
| 313 |
encoded_filename = urllib.parse.quote(downloaded_file.name)
|
| 314 |
download_url = f"{BASE_URL}/file/{encoded_filename}"
|
|
|
|
| 315 |
return {"url": download_url}
|
| 316 |
|
| 317 |
# Configure logging
|
|
@@ -373,6 +378,7 @@ async def search_and_download_song(request: Request):
|
|
| 373 |
|
| 374 |
# Log just before returning the response
|
| 375 |
logging.info("Preparing to send response back to the client")
|
|
|
|
| 376 |
return JSONResponse(content={"url": download_url}, status_code=200)
|
| 377 |
|
| 378 |
# Mount the static files directory
|
|
|
|
| 29 |
from collections import defaultdict
|
| 30 |
from starlette.responses import JSONResponse
|
| 31 |
import logging
|
| 32 |
+
import gc
|
| 33 |
|
| 34 |
tmp_dir = tempfile.gettempdir()
|
| 35 |
BASE_URL = "https://chrunos-multi.hf.space"
|
|
|
|
| 220 |
# Increment the user's request count
|
| 221 |
user_info["count"] += 1
|
| 222 |
|
| 223 |
+
gc.collect()
|
| 224 |
+
|
| 225 |
return {"url": download_url}
|
| 226 |
|
| 227 |
|
|
|
|
| 278 |
downloaded_file = downloaded_files[0]
|
| 279 |
encoded_filename = urllib.parse.quote(downloaded_file.name)
|
| 280 |
download_url = f"{BASE_URL}/file/{encoded_filename}"
|
| 281 |
+
gc.collect()
|
| 282 |
return {"url": download_url}
|
| 283 |
|
| 284 |
|
|
|
|
| 316 |
downloaded_file = downloaded_files[0]
|
| 317 |
encoded_filename = urllib.parse.quote(downloaded_file.name)
|
| 318 |
download_url = f"{BASE_URL}/file/{encoded_filename}"
|
| 319 |
+
gc.collect()
|
| 320 |
return {"url": download_url}
|
| 321 |
|
| 322 |
# Configure logging
|
|
|
|
| 378 |
|
| 379 |
# Log just before returning the response
|
| 380 |
logging.info("Preparing to send response back to the client")
|
| 381 |
+
gc.collect()
|
| 382 |
return JSONResponse(content={"url": download_url}, status_code=200)
|
| 383 |
|
| 384 |
# Mount the static files directory
|