Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
from fastapi.responses import JSONResponse, FileResponse, Response
|
|
|
|
| 2 |
from fastapi import FastAPI, HTTPException, Request
|
| 3 |
import mimetypes
|
| 4 |
from threading import Thread
|
|
@@ -21,6 +22,17 @@ instance = Instance(id=ID, url=URL, cache_dir=CACHE_DIR, token=TOKEN, repo=REPO,
|
|
| 21 |
|
| 22 |
app = FastAPI()
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
async def serve_video(file_path: str, request: Request):
|
| 25 |
"""Serve video file with support for range requests."""
|
| 26 |
if not os.path.isfile(file_path):
|
|
|
|
| 1 |
from fastapi.responses import JSONResponse, FileResponse, Response
|
| 2 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
from fastapi import FastAPI, HTTPException, Request
|
| 4 |
import mimetypes
|
| 5 |
from threading import Thread
|
|
|
|
| 22 |
|
| 23 |
app = FastAPI()
|
| 24 |
|
| 25 |
+
origins = ["*"]
|
| 26 |
+
|
| 27 |
+
app.add_middleware(
|
| 28 |
+
CORSMiddleware,
|
| 29 |
+
allow_origins=origins,
|
| 30 |
+
allow_credentials=True,
|
| 31 |
+
allow_methods=["*"],
|
| 32 |
+
allow_headers=["*"],
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
async def serve_video(file_path: str, request: Request):
|
| 37 |
"""Serve video file with support for range requests."""
|
| 38 |
if not os.path.isfile(file_path):
|