Spaces:
Running
Running
| import os | |
| os.environ["HF_HOME"] = "/tmp/hf_cache" | |
| os.makedirs("/tmp/hf_cache", exist_ok=True) | |
| from fastapi import FastAPI, Query | |
| from huggingface_hub import list_repo_files, hf_hub_download, upload_file | |
| import io | |
| import requests | |
| from fastapi import BackgroundTasks | |
| from fastapi import FastAPI, UploadFile, File | |
| from fastapi.middleware.cors import CORSMiddleware | |
| import os | |
| import os | |
| import zipfile | |
| import tempfile # ✅ Add this! | |
| app = FastAPI() | |
| # CORS setup to allow requests from your frontend | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["*"], # Replace "*" with your frontend domain in production | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| def health_check(): | |
| return {"status": "✅ FastAPI running on Hugging Face Spaces!"} | |