Spaces:
Sleeping
Sleeping
from fastapi import FastAPI | |
from fastapi.middleware.cors import CORSMiddleware | |
import uvicorn | |
app = FastAPI() | |
# Add CORS middleware to allow requests from any origin | |
app.add_middleware( | |
CORSMiddleware, | |
allow_origins=["*"], | |
allow_credentials=True, | |
allow_methods=["*"], | |
allow_headers=["*"], | |
) | |
async def read_root(): | |
return {"Hello": "World"} | |
# Function to run the app in Hugging Face Spaces | |
def run(): | |
uvicorn.run(app, host="0.0.0.0", port=7860) | |
if __name__ == "__main__": | |
run() | |