If load_dotenv() is not called before importing modules that rely on environment variables defined in the .env file, those modules might not be able to access the environment variables correctly. This could lead to errors or unexpected behavior in your code.
25 lines
612 B
Python
25 lines
612 B
Python
from dotenv import load_dotenv
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from routes import screenshot, generate_code, home, evals
|
|
|
|
# Load environment variables first
|
|
load_dotenv()
|
|
|
|
app = FastAPI(openapi_url=None, docs_url=None, redoc_url=None)
|
|
|
|
# Configure CORS settings
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Add routes
|
|
app.include_router(generate_code.router)
|
|
app.include_router(screenshot.router)
|
|
app.include_router(home.router)
|
|
app.include_router(evals.router)
|