|
from fastapi import FastAPI, UploadFile, File, Form, Request, HTTPException |
|
from fastapi.middleware.cors import CORSMiddleware |
|
import os |
|
from dotenv import load_dotenv |
|
from routes import routers, session_files, active_tasks, benchmark |
|
|
|
|
|
load_dotenv() |
|
|
|
|
|
hf_token = os.getenv("HF_TOKEN") |
|
if not hf_token: |
|
print("Warning: HF_TOKEN environment variable is not set. Make sure it's defined in your .env file.") |
|
|
|
hf_organization = os.getenv("HF_ORGANIZATION") |
|
if not hf_organization: |
|
print("Warning: HF_ORGANIZATION environment variable is not set. Make sure it's defined in your .env file.") |
|
|
|
app = FastAPI(title="Yourbench API") |
|
|
|
|
|
app.add_middleware( |
|
CORSMiddleware, |
|
allow_origins=["*"], |
|
allow_credentials=True, |
|
allow_methods=["*"], |
|
allow_headers=["*"], |
|
) |
|
|
|
|
|
@app.on_event("startup") |
|
async def startup_event(): |
|
print("Application startup") |
|
print(f"Initial session_files: {session_files}") |
|
|
|
|
|
for router in routers: |
|
app.include_router(router) |