import core.db as db
import uvicorn 
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from api.v0.user import router as user_router
from fastapi.staticfiles import StaticFiles
from api.v0.poster import router as poster_router
from api.v0.feedback import router as feedback_router

db.initialize_database()



app = FastAPI()
app.include_router(user_router)
app.include_router(poster_router)
app.include_router(feedback_router)
app.mount("/res", StaticFiles(directory="res"), name="res")


app.add_middleware(
    CORSMiddleware,
    allow_origins=["http://localhost:3000"],
    allow_credentials=True,
    allow_methods=["*"],  
    allow_headers=["*"],  
)

if __name__ == "__main__":
    uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True, workers=1)