teacher-ai-api / app /main.py
huyhoang04's picture
Update app/main.py
d776a06 verified
raw
history blame contribute delete
718 Bytes
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.api import ask, rewrite, home
import os
# Set folder cache ở /tmp
cache_dir = "/tmp/cache"
os.environ["HF_HOME"] = cache_dir
os.environ["TRANSFORMERS_CACHE"] = cache_dir
os.environ["TORCH_HOME"] = cache_dir
# Tạo folder cache ở /tmp
os.makedirs(cache_dir, exist_ok=True)
app = FastAPI()
# Add CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Allows all origins
allow_credentials=True,
allow_methods=["*"], # Allows all methods
allow_headers=["*"], # Allows all headers
)
app.include_router(ask.router)
app.include_router(rewrite.router)
app.include_router(home.router)