Skip to main content
from pydantic import BaseModel
from fastapi.responses import HTMLResponse

from modal import Image, App, web_endpoint

image = Image.debian_slim().pip_install("boto3")
app = App(image=image)  # Note: prior to April 2024, "app" was called "stub"


class Item(BaseModel):
    name: str
    qty: int = 42


@app.function()
@web_endpoint(method="POST")
def f(item: Item):
    import boto3
    # do things with boto3...
    return HTMLResponse(f"<html>Hello, {item.name}!</html>")