kind of a mess lol but file caching and front end
This commit is contained in:
15
app/main.py
15
app/main.py
@ -1,5 +1,7 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.responses import FileResponse
|
||||
from contextlib import asynccontextmanager
|
||||
import uvicorn
|
||||
import logging
|
||||
@ -64,6 +66,19 @@ app = FastAPI(
|
||||
lifespan=lifespan
|
||||
)
|
||||
|
||||
# Mount static files directory
|
||||
app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
||||
|
||||
# Serve index.html at root
|
||||
@app.get("/")
|
||||
async def read_root():
|
||||
return FileResponse('app/static/index.html')
|
||||
|
||||
# Serve app.js
|
||||
@app.get("/app.js")
|
||||
async def read_app_js():
|
||||
return FileResponse('app/static/app.js')
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
|
Reference in New Issue
Block a user