ui_server.py•902 B
"""
UI server for the Sectional MCP Panel.
"""
import os
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from pathlib import Path
# Create FastAPI application for UI
ui_app = FastAPI(
title="Sectional MCP Panel UI",
description="Web UI for the Sectional MCP Panel",
version="0.1.0",
)
# Get the directory of this file
BASE_DIR = Path(__file__).resolve().parent
# Mount static files
ui_app.mount("/static", StaticFiles(directory=os.path.join(BASE_DIR, "static")), name="static")
# Set up templates
templates = Jinja2Templates(directory=os.path.join(BASE_DIR, "templates"))
@ui_app.get("/", response_class=HTMLResponse)
async def index(request: Request):
"""Render the main UI page."""
return templates.TemplateResponse("index.html", {"request": request})