justapi — /docs

Basic Form Data

Use Form(...) to receive form data:

from justapi import JustAPIApp, Form

app = JustAPIApp()

@app.post("/login")
def login(username: str = Form(...), password: str = Form(...)):
    return {"username": username}

This accepts application/x-www-form-urlencoded requests.

Required vs Optional

@app.post("/items")
def create_item(
    name: str = Form(...),           # required
    description: str = Form(None),   # optional
):
    return {"name": name, "description": description}

Multiple Form Fields

@app.post("/submit")
def submit_form(
    title: str = Form(...),
    body: str = Form(...),
    tags: str = Form(""),
    publish: bool = Form(False),
):
    return {"title": title, "body": body, "tags": tags, "publish": publish}

See Also

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

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