justapi — /docs

Combined Form + File

from justapi import JustAPIApp, UploadFile, File, Form

app = JustAPIApp()

@app.post("/items/")
async def create_item(
    name: str = Form(...),
    description: str = Form(""),
    image: UploadFile = File(None),
):
    result = {"name": name, "description": description}
    if image:
        content = await image.read()
        result["image_size"] = len(content)
    return result

Multiple Files + Form Data

@app.post("/upload/")
async def upload_with_metadata(
    title: str = Form(...),
    tags: list[str] = Form([]),
    files: list[UploadFile] = File(...),
):
    return {
        "title": title,
        "tags": tags,
        "file_count": len(files),
        "filenames": [f.filename for f in files],
    }

See Also

JustAPI v2.0.9 — Open Source MIT License · Built with WebTUI · GitHub

NORMAL master justapi/docs
utf-8 Top 1:1