Spaces:
Sleeping
Sleeping
up
Browse files- Dockerfile +1 -1
- server/app.py +15 -3
Dockerfile
CHANGED
|
@@ -90,5 +90,5 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
| 90 |
|
| 91 |
# Run the FastAPI server
|
| 92 |
# The module path is constructed to work with the /app/env structure
|
| 93 |
-
ENV ENABLE_WEB_INTERFACE=true
|
| 94 |
CMD ["sh", "-c", "cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 8000"]
|
|
|
|
| 90 |
|
| 91 |
# Run the FastAPI server
|
| 92 |
# The module path is constructed to work with the /app/env structure
|
| 93 |
+
# ENV ENABLE_WEB_INTERFACE=true
|
| 94 |
CMD ["sh", "-c", "cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 8000"]
|
server/app.py
CHANGED
|
@@ -39,7 +39,7 @@ except Exception as e: # pragma: no cover
|
|
| 39 |
import importlib
|
| 40 |
from pathlib import Path
|
| 41 |
|
| 42 |
-
from fastapi import HTTPException
|
| 43 |
from fastapi.middleware.cors import CORSMiddleware
|
| 44 |
from fastapi.responses import FileResponse
|
| 45 |
from fastapi.openapi.utils import get_openapi
|
|
@@ -117,8 +117,9 @@ except Exception: # pragma: no cover - tolerate multiple packaging layouts
|
|
| 117 |
raise
|
| 118 |
|
| 119 |
|
| 120 |
-
#
|
| 121 |
-
app
|
|
|
|
| 122 |
SatelliteEnvironment,
|
| 123 |
SatelliteAction,
|
| 124 |
SatelliteObservation,
|
|
@@ -126,6 +127,12 @@ app = create_app(
|
|
| 126 |
max_concurrent_envs=1, # increase this number to allow more concurrent WebSocket sessions
|
| 127 |
)
|
| 128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
app.add_middleware(
|
| 130 |
CORSMiddleware,
|
| 131 |
allow_origins=[
|
|
@@ -139,6 +146,11 @@ app.add_middleware(
|
|
| 139 |
allow_headers=["*"],
|
| 140 |
)
|
| 141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
ui_demo = SatelliteUIDemo()
|
| 143 |
frontend_dist = Path(__file__).resolve().parent.parent / "frontend" / "dist"
|
| 144 |
|
|
|
|
| 39 |
import importlib
|
| 40 |
from pathlib import Path
|
| 41 |
|
| 42 |
+
from fastapi import FastAPI, HTTPException
|
| 43 |
from fastapi.middleware.cors import CORSMiddleware
|
| 44 |
from fastapi.responses import FileResponse
|
| 45 |
from fastapi.openapi.utils import get_openapi
|
|
|
|
| 117 |
raise
|
| 118 |
|
| 119 |
|
| 120 |
+
# Build the OpenEnv API app first, then expose its non-UI routes from our
|
| 121 |
+
# top-level FastAPI app so Hugging Face Spaces can use the custom frontend at `/`.
|
| 122 |
+
openenv_app = create_app(
|
| 123 |
SatelliteEnvironment,
|
| 124 |
SatelliteAction,
|
| 125 |
SatelliteObservation,
|
|
|
|
| 127 |
max_concurrent_envs=1, # increase this number to allow more concurrent WebSocket sessions
|
| 128 |
)
|
| 129 |
|
| 130 |
+
app = FastAPI(
|
| 131 |
+
title="Satellite Mission Tracking",
|
| 132 |
+
version="0.1.0",
|
| 133 |
+
description="Custom satellite mission frontend with mounted OpenEnv API routes.",
|
| 134 |
+
)
|
| 135 |
+
|
| 136 |
app.add_middleware(
|
| 137 |
CORSMiddleware,
|
| 138 |
allow_origins=[
|
|
|
|
| 146 |
allow_headers=["*"],
|
| 147 |
)
|
| 148 |
|
| 149 |
+
for route in openenv_app.router.routes:
|
| 150 |
+
if getattr(route, "path", None) in {"/", "/docs", "/redoc", "/openapi.json"}:
|
| 151 |
+
continue
|
| 152 |
+
app.router.routes.append(route)
|
| 153 |
+
|
| 154 |
ui_demo = SatelliteUIDemo()
|
| 155 |
frontend_dist = Path(__file__).resolve().parent.parent / "frontend" / "dist"
|
| 156 |
|