Skip to content
Programming for the Web

Overview


Your programs have made decisions, organized records, and saved JSON files. In Part 6, a command interface called the application’s model and storage operations. Here a browser becomes the interface to familiar Python functions and records. You will build a small web application that displays, searches, and saves records.

A browser sends a request to a running Python program, called the server. A route function handles the request and returns a response. A template combines records with a page description to produce HTML that the browser displays.

The diagram below connects that browser interface to the Python operations you already know.

The browser interface connects to ordinary Python functions and records.

The chapters form three units, each adding a responsibility to the application:

Finish with the recap and feedback.

Working with the Examples

Set up one web-app folder and its environment in A Walking Skeleton Application, then reuse it throughout the examples. HTML Pages and Links replaces main.py with an HTML version.

Displaying JSON Records with Templates replaces it with a JSON-backed version and adds templates and supporting files. Detail Pages and Identifiers, Filtering and Searching, and Forms and Submission extend those files.

A Guided Study Tasks Application and Connecting Requests to JSON Storage use the resulting application, which handles task records with id, title, and category at /tasks.

The exercises provide starter files in the exercise editor. Some exercises form short chains: complete one to unlock the next, whose starter includes a sample solution to the preceding step. Use each exercise’s supplied files. Choose Show file tree to inspect them, make your changes, and choose Submit for feedback. The editor’s Python Run command is disabled for these web exercises.

For the local examples, predict the response before making a request. Compare your prediction with the page, the returned HTML, and the server terminal.