""" web/app.py ---------- FastAPI entrypoint for the Adobe Sign → DocuSign Migrator web app. Run with: uvicorn web.app:app --reload --port 8000 From the project root. """ from fastapi import FastAPI from fastapi.staticfiles import StaticFiles from fastapi.responses import FileResponse, HTMLResponse import logging import os from web.config import settings from web.routers import auth, templates, migrate, verify, audit, admin import sys sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) from src.utils.log_sanitizer import install_sanitizing_filter install_sanitizing_filter() logger = logging.getLogger(__name__) _DEFAULT_SECRET = "dev-secret-change-in-production" if settings.session_secret_key == _DEFAULT_SECRET: logger.warning( "SESSION_SECRET_KEY is using the default dev value — set a random secret in .env before exposing this app" ) app = FastAPI( title="Adobe Sign → DocuSign Migrator", version=settings.version, docs_url="/api/docs", ) # Routers app.include_router(auth.router, prefix="/api/auth", tags=["auth"]) app.include_router(templates.router, prefix="/api/templates", tags=["templates"]) app.include_router(migrate.router, prefix="/api/migrate", tags=["migrate"]) app.include_router(verify.router, prefix="/api/verify", tags=["verify"]) app.include_router(audit.router, prefix="/api/audit", tags=["audit"]) app.include_router(admin.router, prefix="/api/admin", tags=["admin"]) # Static files (frontend) _static_dir = os.path.join(os.path.dirname(__file__), "static") if os.path.isdir(_static_dir): app.mount("/static", StaticFiles(directory=_static_dir), name="static") @app.get("/health", tags=["health"]) def health(): return {"status": "ok", "version": settings.version} @app.get("/", include_in_schema=False) def index(): index_path = os.path.join(_static_dir, "index.html") if os.path.exists(index_path): with open(index_path, encoding="utf-8") as f: html = f.read() html = html.replace("{{ASSET_VERSION}}", settings.asset_version) return HTMLResponse(html) return {"message": "Adobe Sign → DocuSign Migrator API", "docs": "/api/docs"}