remove the download code
Browse files- routes/summarize.py +5 -16
routes/summarize.py
CHANGED
|
@@ -1,14 +1,15 @@
|
|
| 1 |
from fastapi import APIRouter, UploadFile, File
|
| 2 |
-
from fastapi.responses import JSONResponse
|
| 3 |
from services.extractor import extract_features
|
| 4 |
from services.summarizer import get_scores, get_selected_indices, save_summary_video
|
|
|
|
| 5 |
import time
|
| 6 |
import os
|
| 7 |
|
| 8 |
router = APIRouter()
|
| 9 |
|
| 10 |
-
|
| 11 |
@router.post("/summarize")
|
|
|
|
| 12 |
def summarize_video(video: UploadFile = File(...)):
|
| 13 |
if not video.filename.lower().endswith(('.mp4', '.avi', '.mov', '.mkv')):
|
| 14 |
return JSONResponse(content={"error": "Unsupported file format"}, status_code=400)
|
|
@@ -20,7 +21,6 @@ def summarize_video(video: UploadFile = File(...)):
|
|
| 20 |
filepath = os.path.join(os.getcwd(), "static", filename)
|
| 21 |
processed_filepath = os.path.join(os.getcwd(), "static", processed_filename)
|
| 22 |
url = f"/static/{processed_filename}"
|
| 23 |
-
download_url = f"/download/{processed_filename}"
|
| 24 |
|
| 25 |
print("\n-----------> Saving Video Locally ....")
|
| 26 |
with open(filepath, "wb") as f:
|
|
@@ -41,16 +41,5 @@ def summarize_video(video: UploadFile = File(...)):
|
|
| 41 |
print("\n-----------> Returning Response ....")
|
| 42 |
return JSONResponse(content={
|
| 43 |
"message": "Summarization complete",
|
| 44 |
-
"summary_video_url": url
|
| 45 |
-
|
| 46 |
-
})
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
@router.get("/download/{filename}")
|
| 50 |
-
def download_summary(filename: str):
|
| 51 |
-
file_path = os.path.join(os.getcwd(), "static", filename)
|
| 52 |
-
return FileResponse(
|
| 53 |
-
path=file_path,
|
| 54 |
-
filename=filename,
|
| 55 |
-
media_type='application/octet-stream'
|
| 56 |
-
)
|
|
|
|
| 1 |
from fastapi import APIRouter, UploadFile, File
|
| 2 |
+
from fastapi.responses import JSONResponse
|
| 3 |
from services.extractor import extract_features
|
| 4 |
from services.summarizer import get_scores, get_selected_indices, save_summary_video
|
| 5 |
+
from uuid import uuid4
|
| 6 |
import time
|
| 7 |
import os
|
| 8 |
|
| 9 |
router = APIRouter()
|
| 10 |
|
|
|
|
| 11 |
@router.post("/summarize")
|
| 12 |
+
|
| 13 |
def summarize_video(video: UploadFile = File(...)):
|
| 14 |
if not video.filename.lower().endswith(('.mp4', '.avi', '.mov', '.mkv')):
|
| 15 |
return JSONResponse(content={"error": "Unsupported file format"}, status_code=400)
|
|
|
|
| 21 |
filepath = os.path.join(os.getcwd(), "static", filename)
|
| 22 |
processed_filepath = os.path.join(os.getcwd(), "static", processed_filename)
|
| 23 |
url = f"/static/{processed_filename}"
|
|
|
|
| 24 |
|
| 25 |
print("\n-----------> Saving Video Locally ....")
|
| 26 |
with open(filepath, "wb") as f:
|
|
|
|
| 41 |
print("\n-----------> Returning Response ....")
|
| 42 |
return JSONResponse(content={
|
| 43 |
"message": "Summarization complete",
|
| 44 |
+
"summary_video_url": url
|
| 45 |
+
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|