Spaces:
Sleeping
Sleeping
adityaverma977 commited on
Commit ·
3890926
1
Parent(s): b2c8834
Fix backend inference logging and improvements
Browse files- app/main.py +13 -4
- backend/app/main.py +13 -4
app/main.py
CHANGED
|
@@ -22,10 +22,19 @@ from . import hf_spaces
|
|
| 22 |
|
| 23 |
app = FastAPI(title="Unhinged 2.0", version="0.2.0")
|
| 24 |
|
| 25 |
-
|
| 26 |
-
"
|
| 27 |
-
"http://localhost:
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
app.add_middleware(
|
| 31 |
CORSMiddleware,
|
|
|
|
| 22 |
|
| 23 |
app = FastAPI(title="Unhinged 2.0", version="0.2.0")
|
| 24 |
|
| 25 |
+
_DEFAULT_ALLOWED_ORIGINS = [
|
| 26 |
+
"http://localhost:3000",
|
| 27 |
+
"http://localhost:3001",
|
| 28 |
+
"http://localhost:3002",
|
| 29 |
+
"http://127.0.0.1:3000",
|
| 30 |
+
"http://127.0.0.1:3001",
|
| 31 |
+
"http://127.0.0.1:3002",
|
| 32 |
+
]
|
| 33 |
+
_configured_origins = os.environ.get("ALLOWED_ORIGINS", "").strip()
|
| 34 |
+
if _configured_origins:
|
| 35 |
+
ALLOWED_ORIGINS = [origin.strip() for origin in _configured_origins.split(",") if origin.strip()]
|
| 36 |
+
else:
|
| 37 |
+
ALLOWED_ORIGINS = _DEFAULT_ALLOWED_ORIGINS
|
| 38 |
|
| 39 |
app.add_middleware(
|
| 40 |
CORSMiddleware,
|
backend/app/main.py
CHANGED
|
@@ -21,10 +21,19 @@ from . import hf_spaces
|
|
| 21 |
|
| 22 |
app = FastAPI(title="Unhinged 2.0", version="0.2.0")
|
| 23 |
|
| 24 |
-
|
| 25 |
-
"
|
| 26 |
-
"http://localhost:
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
app.add_middleware(
|
| 30 |
CORSMiddleware,
|
|
|
|
| 21 |
|
| 22 |
app = FastAPI(title="Unhinged 2.0", version="0.2.0")
|
| 23 |
|
| 24 |
+
_DEFAULT_ALLOWED_ORIGINS = [
|
| 25 |
+
"http://localhost:3000",
|
| 26 |
+
"http://localhost:3001",
|
| 27 |
+
"http://localhost:3002",
|
| 28 |
+
"http://127.0.0.1:3000",
|
| 29 |
+
"http://127.0.0.1:3001",
|
| 30 |
+
"http://127.0.0.1:3002",
|
| 31 |
+
]
|
| 32 |
+
_configured_origins = os.environ.get("ALLOWED_ORIGINS", "").strip()
|
| 33 |
+
if _configured_origins:
|
| 34 |
+
ALLOWED_ORIGINS = [origin.strip() for origin in _configured_origins.split(",") if origin.strip()]
|
| 35 |
+
else:
|
| 36 |
+
ALLOWED_ORIGINS = _DEFAULT_ALLOWED_ORIGINS
|
| 37 |
|
| 38 |
app.add_middleware(
|
| 39 |
CORSMiddleware,
|