Spaces:
Configuration error
Configuration error
Braden Wong
commited on
Commit
·
9d4a9a2
1
Parent(s):
323aa51
feat: add CORS support, loaded from CORS_ORIGINS in env
Browse files
faster_whisper_server/main.py
CHANGED
@@ -77,6 +77,17 @@ def load_model(model_name: str) -> WhisperModel:
|
|
77 |
|
78 |
app = FastAPI()
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
@app.get("/health")
|
82 |
def health() -> Response:
|
|
|
77 |
|
78 |
app = FastAPI()
|
79 |
|
80 |
+
cors_origins = os.environ.get("CORS_ORIGINS", "").split(",")
|
81 |
+
if cors_origins:
|
82 |
+
app.add_middleware(
|
83 |
+
CORSMiddleware,
|
84 |
+
allow_origins=cors_origins,
|
85 |
+
allow_credentials=True,
|
86 |
+
allow_methods=["*"],
|
87 |
+
allow_headers=["*"],
|
88 |
+
)
|
89 |
+
|
90 |
+
|
91 |
|
92 |
@app.get("/health")
|
93 |
def health() -> Response:
|