File size: 413 Bytes
edf3685
 
8d7f55f
edf3685
16d2214
edf3685
 
 
 
 
 
16d2214
edf3685
 
 
 
16d2214
edf3685
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()

# Sample request model
class Item(BaseModel):
    name: str
    description: str
    price: float
    tax: float

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

# POST endpoint
@app.post("/items/")
def create_item(item: Item):
    return {"item": item}