|
@ -1,3 +1,5 @@ |
|
|
|
|
|
import asyncio |
|
|
|
|
|
|
|
|
from fastapi import FastAPI, Response, BackgroundTasks, Header, Request |
|
|
from fastapi import FastAPI, Response, BackgroundTasks, Header, Request |
|
|
from fastapi.responses import StreamingResponse, FileResponse |
|
|
from fastapi.responses import StreamingResponse, FileResponse |
|
|
from fastapi.security import HTTPBasic, HTTPBasicCredentials |
|
|
from fastapi.security import HTTPBasic, HTTPBasicCredentials |
|
@ -247,7 +249,7 @@ class Server: |
|
|
headers.update({"Content-Length":str(os.path.getsize(preview))}) |
|
|
headers.update({"Content-Length":str(os.path.getsize(preview))}) |
|
|
headers.update({"Content-Disposition": f'attachment; filename="preview.webp"'}) |
|
|
headers.update({"Content-Disposition": f'attachment; filename="preview.webp"'}) |
|
|
return FileResponse(preview, media_type="application/octet-stream", headers=headers) |
|
|
return FileResponse(preview, media_type="application/octet-stream", headers=headers) |
|
|
except NeedNVR: |
|
|
except NeedNVR | FileNotFoundError: |
|
|
background_tasks.add_task(loadPreview, file = file) |
|
|
background_tasks.add_task(loadPreview, file = file) |
|
|
return FileResponse("./assets/loading.webp") |
|
|
return FileResponse("./assets/loading.webp") |
|
|
|
|
|
|
|
|