File size: 591 Bytes
edf3685
dff0bf1
 
 
 
 
 
 
 
 
8d7f55f
e32fd5c
edf3685
16d2214
edf3685
 
 
 
e32fd5c
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],  # Allow all origins for simplicity, or specify domains
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# Define FastAPI app
app = FastAPI()

# Basic GET endpoint
@app.get("/")
def read_root():
    return {"message": "Welcome to the FastAPI app on Hugging Face Spaces!"}

# If running as the main module, start Uvicorn
if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=7860)