Spaces:
Sleeping
Sleeping
Added cors support
Browse files
main.py
CHANGED
|
@@ -6,6 +6,7 @@ import os
|
|
| 6 |
import uuid
|
| 7 |
import logging
|
| 8 |
from fastapi.staticfiles import StaticFiles
|
|
|
|
| 9 |
|
| 10 |
class Url(BaseModel):
|
| 11 |
url: str
|
|
@@ -17,6 +18,17 @@ MODEL=os.environ['model']
|
|
| 17 |
|
| 18 |
app = FastAPI()
|
| 19 |
app.mount("/tracks", StaticFiles(directory="/tmp/holosubs/results"), name="tracks")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
@app.post("/captions/")
|
| 21 |
def read_root(url: Url):
|
| 22 |
# Download wav file and get filename
|
|
|
|
| 6 |
import uuid
|
| 7 |
import logging
|
| 8 |
from fastapi.staticfiles import StaticFiles
|
| 9 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 10 |
|
| 11 |
class Url(BaseModel):
|
| 12 |
url: str
|
|
|
|
| 18 |
|
| 19 |
app = FastAPI()
|
| 20 |
app.mount("/tracks", StaticFiles(directory="/tmp/holosubs/results"), name="tracks")
|
| 21 |
+
|
| 22 |
+
# CORS
|
| 23 |
+
origins = ["*"]
|
| 24 |
+
app.add_middleware(
|
| 25 |
+
CORSMiddleware,
|
| 26 |
+
allow_origins=origins,
|
| 27 |
+
allow_credentials=True,
|
| 28 |
+
allow_methods=["*"],
|
| 29 |
+
allow_headers=["*"],
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
@app.post("/captions/")
|
| 33 |
def read_root(url: Url):
|
| 34 |
# Download wav file and get filename
|