1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
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()
|