Spaces:
Sleeping
Sleeping
bigwolfe
commited on
Commit
·
a7be466
1
Parent(s):
d97497a
docker changes for oauth
Browse files- Dockerfile +1 -1
- backend/src/api/main.py +22 -10
- frontend/src/pages/Settings.tsx +8 -3
Dockerfile
CHANGED
|
@@ -17,7 +17,7 @@ COPY frontend/ frontend/
|
|
| 17 |
RUN cd frontend && npm run build
|
| 18 |
|
| 19 |
# Install Python dependencies
|
| 20 |
-
COPY backend/pyproject.toml backend/
|
| 21 |
RUN pip install --no-cache-dir -e backend/
|
| 22 |
|
| 23 |
# Copy backend source
|
|
|
|
| 17 |
RUN cd frontend && npm run build
|
| 18 |
|
| 19 |
# Install Python dependencies
|
| 20 |
+
COPY backend/pyproject.toml backend/README.md backend/
|
| 21 |
RUN pip install --no-cache-dir -e backend/
|
| 22 |
|
| 23 |
# Copy backend source
|
backend/src/api/main.py
CHANGED
|
@@ -79,13 +79,10 @@ app.include_router(notes.router, tags=["notes"])
|
|
| 79 |
app.include_router(search.router, tags=["search"])
|
| 80 |
app.include_router(index.router, tags=["index"])
|
| 81 |
|
| 82 |
-
#
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
logger.info("MCP HTTP endpoint mounted at /mcp")
|
| 87 |
-
except Exception as e:
|
| 88 |
-
logger.warning(f"Failed to mount MCP HTTP endpoint: {e}")
|
| 89 |
|
| 90 |
|
| 91 |
@app.get("/health")
|
|
@@ -94,11 +91,26 @@ async def health():
|
|
| 94 |
return {"status": "healthy"}
|
| 95 |
|
| 96 |
|
| 97 |
-
# Serve frontend static files (must be last to not override API routes)
|
|
|
|
|
|
|
| 98 |
frontend_dist = Path(__file__).resolve().parents[3] / "frontend" / "dist"
|
| 99 |
if frontend_dist.exists():
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
else:
|
| 103 |
logger.warning(f"Frontend dist not found at: {frontend_dist}")
|
| 104 |
|
|
|
|
| 79 |
app.include_router(search.router, tags=["search"])
|
| 80 |
app.include_router(index.router, tags=["index"])
|
| 81 |
|
| 82 |
+
# Note: FastMCP HTTP mode is typically run as a separate server
|
| 83 |
+
# For HF Space deployment, MCP is primarily used via STDIO in local development
|
| 84 |
+
# To use MCP HTTP, run: fastmcp run backend.src.mcp.server:mcp --port 8001
|
| 85 |
+
logger.info("MCP server available for STDIO mode (local development)")
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
|
| 88 |
@app.get("/health")
|
|
|
|
| 91 |
return {"status": "healthy"}
|
| 92 |
|
| 93 |
|
| 94 |
+
# Serve frontend static files with SPA support (must be last to not override API routes)
|
| 95 |
+
from fastapi.responses import FileResponse
|
| 96 |
+
|
| 97 |
frontend_dist = Path(__file__).resolve().parents[3] / "frontend" / "dist"
|
| 98 |
if frontend_dist.exists():
|
| 99 |
+
# Mount static assets
|
| 100 |
+
app.mount("/assets", StaticFiles(directory=str(frontend_dist / "assets")), name="assets")
|
| 101 |
+
|
| 102 |
+
# Catch-all route for SPA - serve index.html for all non-API routes
|
| 103 |
+
@app.get("/{full_path:path}")
|
| 104 |
+
async def serve_spa(full_path: str):
|
| 105 |
+
"""Serve the SPA for all non-API routes."""
|
| 106 |
+
# If the path looks like a file (has extension), try to serve it
|
| 107 |
+
file_path = frontend_dist / full_path
|
| 108 |
+
if file_path.is_file():
|
| 109 |
+
return FileResponse(file_path)
|
| 110 |
+
# Otherwise serve index.html for SPA routing
|
| 111 |
+
return FileResponse(frontend_dist / "index.html")
|
| 112 |
+
|
| 113 |
+
logger.info(f"Serving frontend SPA from: {frontend_dist}")
|
| 114 |
else:
|
| 115 |
logger.warning(f"Frontend dist not found at: {frontend_dist}")
|
| 116 |
|
frontend/src/pages/Settings.tsx
CHANGED
|
@@ -123,9 +123,14 @@ export function Settings() {
|
|
| 123 |
|
| 124 |
{/* Profile */}
|
| 125 |
<Card>
|
| 126 |
-
<CardHeader>
|
| 127 |
-
<
|
| 128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
</CardHeader>
|
| 130 |
<CardContent>
|
| 131 |
{user ? (
|
|
|
|
| 123 |
|
| 124 |
{/* Profile */}
|
| 125 |
<Card>
|
| 126 |
+
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
| 127 |
+
<div>
|
| 128 |
+
<CardTitle>Profile</CardTitle>
|
| 129 |
+
<CardDescription>Your account information</CardDescription>
|
| 130 |
+
</div>
|
| 131 |
+
<Button variant="outline" size="sm" onClick={logout}>
|
| 132 |
+
Sign Out
|
| 133 |
+
</Button>
|
| 134 |
</CardHeader>
|
| 135 |
<CardContent>
|
| 136 |
{user ? (
|