MCPcopy Create free account
hub / github.com/adafruit/Adafruit_CircuitPython_HTTPServer / form

Function form

examples/httpserver_form_data.py:42–62  ·  view source on GitHub ↗

Serve a form with the given enctype, and display back the submitted value.

(request: Request)

Source from the content-addressed store, hash-verified

40
41@server.route("/form", [GET, POST])
42def form(request: Request):
43 """
44 Serve a form with the given enctype, and display back the submitted value.
45 """
46 enctype = request.query_params.get("enctype", "text/plain")
47
48 if request.method == POST:
49 posted_value = request.form_data.get("something")
50
51 return Response(
52 request,
53 FORM_HTML_TEMPLATE.format(
54 enctype=enctype,
55 submitted_value=(
56 f"<h3>Enctype: {enctype}</h3>\n<h3>Submitted form value: {posted_value}</h3>"
57 if request.method == POST
58 else ""
59 ),
60 ),
61 content_type="text/html",
62 )
63
64
65server.serve_forever(str(wifi.radio.ipv4_address))

Callers

nothing calls this directly

Calls 2

ResponseClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected