square-api / app.py
martper56's picture
Create app.py
f56ac51 verified
raw
history blame
268 Bytes
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class NumberInput(BaseModel):
number: float
@app.post("/square")
def compute_square(data: NumberInput):
result = data.number ** 2
return {"input": data.number, "square": result}