17. docker deployment
This commit is contained in:
@ -5,8 +5,10 @@ REST API server for COBY system.
|
||||
from fastapi import FastAPI, HTTPException, Request, Query, Path
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from typing import Optional, List
|
||||
import asyncio
|
||||
import os
|
||||
from ..config import config
|
||||
from ..caching.redis_manager import redis_manager
|
||||
from ..utils.logging import get_logger, set_correlation_id
|
||||
@ -17,7 +19,7 @@ from .response_formatter import ResponseFormatter
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
def create_app() -> FastAPI:
|
||||
def create_app(config_obj=None) -> FastAPI:
|
||||
"""Create and configure FastAPI application"""
|
||||
|
||||
app = FastAPI(
|
||||
@ -28,6 +30,13 @@ def create_app() -> FastAPI:
|
||||
redoc_url="/redoc"
|
||||
)
|
||||
|
||||
# Mount static files for web dashboard (since we removed nginx)
|
||||
static_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "web", "static")
|
||||
if os.path.exists(static_path):
|
||||
app.mount("/static", StaticFiles(directory=static_path), name="static")
|
||||
# Serve index.html at root for dashboard
|
||||
app.mount("/", StaticFiles(directory=static_path, html=True), name="dashboard")
|
||||
|
||||
# Add CORS middleware
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
|
Reference in New Issue
Block a user