from typing import Any from fastapi import FastAPI from fastapi.responses import HTMLResponse from starlette.middleware.cors import CORSMiddleware from starlette.middleware.trustedhost import TrustedHostMiddleware from jb.config import settings from jb.settings import render_base_html from jb.views.auth import auth_router from jb.views.wallet import wallet_router app = FastAPI( servers=[ { "url": "https://jamesbillings67.com/", "description": "Production environment", }, ], title="jb", version="1.0.0", ) app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) app.add_middleware(TrustedHostMiddleware, allowed_hosts=["*"]) app.include_router(router=auth_router) app.include_router(router=wallet_router) @app.get("/robots.txt") @app.get("/sitemap.xml") @app.get("/favicon.ico") def return_nothing() -> dict[str, Any]: return {} @app.get("/{full_path:path}") def serve_react_app(full_path: str): # This serves index.html for any unmatched route # React Router will then handle the client-side routing return HTMLResponse( render_base_html(), headers={ "Cache-Control": "no-cache, no-store, must-revalidate", "Pragma": "no-cache", "Expires": "0", }, ) def schedule_tasks(): pass # Process(target=example_task).start() if not settings.debug: schedule_tasks()