Digital services: understandable forms and dependable contracts
Three linked practical lessons. Suggested allowance: 45–75 minutes per lesson, plus setup; not measured learner time. Prerequisites: HTML forms, basic Python and the linked chapters. Use only synthetic values.
Try the local form
Enter a synthetic order ID and integer amount in paise. Required fields are labelled. Nothing is sent or saved. This is a validation exercise, not an ordering service.
Run HTTP/API locally
python3 service_practice.py python3 -m unittest service_practice_test.py
Keep all three files together. The server is temporary and loopback-only. Compare printed output with service_expected.json. Website hosting does not run this Python server. Download the form source through service-form.js and this HTML page if inspecting locally.
Accessible forms: correction is part of the task
Expected: Blank fields show specific errors; valid synthetic input gives a local confirmation.
A form is a conversation about a task, not merely a collection of boxes. The learner should understand what information is needed, which unit to use and how to recover from an error. This exercise names the order identifier and amount in paise through explicit visible labels. Instructions and error messages are associated with their fields using aria-describedby. A status area reports correction needs or a local validation result, and the first invalid field receives focus after submission.
Start with both fields blank and submit. Predict two field errors. Enter O1 and a negative amount: the amount still needs correction. Enter O1 and 10000: the local confirmation explains that validation passed and that no order was sent or saved. A confirmation must not imply that a business transaction occurred when the page merely checked input. Preserving entered values allows correction without making the learner repeat valid work.
Use the keyboard to reach each control, enter values and activate the button. Inspect focus visibility, reading order, labels and error associations. Where possible test with a screen reader and different zoom settings, recording actual observations rather than claiming universal accessibility from markup. Automated DOM checks can establish some relationships and behaviour; they do not replace assistive-technology and user testing. This exercise is not a WCAG conformance audit.
Customer service should help define language that users understand. Finance defines the amount unit and permitted values; IT implements the interaction; accessibility participants reveal barriers that technical authors may miss. Ask whom an error affects and whose feedback reaches the design team. Avoid unnecessarily collecting identity or contact information. The synthetic form stores no response and makes no network request.
Foundation: explain why a placeholder is insufficient as the only label. Undergraduate: inspect label and error references. Postgraduate: critique recovery, focus and confirmation semantics. Research: design a task study with participant consent, observable outcomes and attention to unequal access. Submit blank, invalid and valid cases, keyboard observations and one improvement supported by evidence.
HTTP tracing: transport evidence and business meaning
Expected: Loopback trace statuses: 201,200,409,400,200,404.
HTTP connects requests and responses, but a status is only part of the evidence a business application needs. The supplied Python program starts a temporary server on 127.0.0.1 with an operating-system-selected port. It sends six requests to that local address, prints their status and JSON body, then shuts the server down. There is no external service, account or cloud bill. Run it locally rather than expecting Cloudflare Pages to execute Python.
The first POST creates O1 at 10000 paise and returns 201. Sending identical content again returns 200 with replay true under this classroom contract. Changing the same identifier's amount returns 409 without overwriting the original. Malformed JSON returns 400. GET /orders returns 200 with one stored order; an unknown path returns 404. Predict every response before running, then inspect the returned body rather than reading the status alone.
A successful transport response does not independently prove a payment, dispatch or durable business commitment. This store exists only in memory and disappears with the process. Replay handling is an explicit application policy, not a promise that all POST operations are inherently idempotent. A production client also needs timeouts, retry policy and a way to investigate uncertain outcomes. A response lost after a successful write is a different event from a write that never occurred.
Use browser developer tools on a site you control to distinguish method, path, headers and response body, without sending sensitive data. For this fixture the Python trace provides reproducible observations. The bounded server does not implement TLS, authentication, durable transactions, concurrent replay guarantees or comprehensive HTTP parsing. Do not expose it publicly. Its purpose is to make request evidence understandable.
Foundation: distinguish request from response. Undergraduate: explain all six results. Postgraduate: propose recovery for an ambiguous timeout. Research: define an event study of failed requests and customer outcomes with suitable privacy boundaries. Submit the trace, a status/body explanation and a departmental escalation plan for conflicting identifiers.
API contracts: shared meanings and conflict ownership
Expected: Exact keys required; invalid types rejected; identical replay accepted; changed replay conflicts.
An API contract tells different systems what a request means and what evidence they should expect in return. This contract accepts exactly order_id and amount_paise for POST /orders. The identifier must be trimmed, nonblank and at most forty characters. The amount must be an integer between zero and 100000000 paise. Python booleans are explicitly rejected as amounts even though their type relationship can otherwise make a numeric check too permissive. The value is paise, not rupees.
Read OrderStore.request() and predict a missing key, an extra key, a string amount, a negative value and an unsupported media type. Valid syntax does not guarantee contract validity. An array can be valid JSON while failing the required object structure. The contract rejects unsupported content rather than silently guessing how to interpret it. Clients should present actionable messages and preserve valid entries for correction.
An identifier carries a replay policy here: identical payloads return the existing result; different payloads conflict. Sales may believe an amount change is a correction, while finance may require authorisation. Returning 409 exposes that disagreement instead of deciding it silently. A proper correction route would need versioning, authority, evidence and history. This fixture offers no update endpoint and makes no assertion that its simple policy meets a real firm's requirements.
The form and API are deliberately separate exercises. Passing browser validation is not a server write, and bypassing the form must not bypass server validation. Compare their amount rules: the form rejects leading-zero amount strings while the API receives a JSON integer. A contract review should explain such differences rather than pretend two implementations are identical. Authentication and authorisation would also need independent design before real use.
Foundation: explain a field contract. Undergraduate: reproduce rejected cases. Postgraduate: design compatibility and authorised correction policies. Research: propose how to study contract misunderstandings across departments using defined error measures. Submit a contract table, replay/conflict evidence, client/server boundary analysis and a consultation memo naming owners for identifiers, units and exceptions.
Free primary learning
Selected public guidance checked 5 October 2026; these are documentation resources, not newly verified degree syllabi. DOM tests and explicit labels do not establish full accessibility. Test assistive technology and actual user tasks separately.