Spaces:
Paused
Paused
File size: 718 Bytes
ac1134b d776a06 ac1134b d776a06 ac1134b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
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)
|