trial2 / space.py
alaa-ahmed14's picture
Create space.py
cf07078 verified
raw
history blame contribute delete
528 Bytes
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=["*"],
)
@app.get("/")
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()