Skip to content

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.

@app.post("/items")
def create_item(
name: str = Form(...), # required
description: str = Form(None), # optional
):
return {"name": name, "description": description}
@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}