File size: 319 Bytes
14c36bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from fastapi import FastAPI

app = FastAPI()

# Define a route
@app.get("/api/greet")
def greet(name: str = "World"):
    return {"message": f"Hello, {name}!"}

# Run the server (use Uvicorn)
# Command: uvicorn app:app --reload

@app.get("/")
def read_root():
    return {"message": "Hello from Hugging Face Spaces!"}