← Code

Web apps with Flask

Put Python behind your own web pages.

Start1. A page from Python
For teachers Usually Years 9–10 · 5 lessons (and 2 optional)

Your own HTML pages with Python behind them: routes, pages built from data, forms, saving to a file and JSON, ending with the same API in FastAPI.

  • Usually Years 9–10
  • Lessons 5 (and 2 optional)
  • Do first Console bridge: text in, text out and Structure and style a page
Teacher guide

Standards, in general: main focus: Trace algorithms for errors (8P06); touches on: Acquire and validate data (8P01), Implement modular programs with OOP (10P09), Acquire, store and validate data (10P01), Analyse and visualise data (10P02). What this means

Pages from Python

Routes join addresses to functions; templates build pages from data.

1A page from PythonNot started
2Pages from dataNot started

Forms and saving

Take answers from a form, check them, and save them to a file so they last.

3Join the clubNot started

Make the club page's sign-up form work: the form sends its answers, a route reads them, adds the new member and goes back home.

  1. Predict
  2. Run
  3. Investigate › Back home
  4. Investigate › A choice from a list
  5. Investigate › Spot the bug
  6. Modify › No blank names
  7. Modify › Year level
  8. Record a win
  9. Where this leads
Start lesson
4Keep the sign-upsNot started

APIs

Send data as JSON for other programs, then the same API in FastAPI.

5An API for the clubNot started

Send the club's data as JSON, so other programs (an app, a game, another website) can read it: routes that return data instead of pages.

  1. Predict
  2. Run
  3. Investigate › Data for programs
  4. Investigate › An empty answer
  5. Investigate › Spot the bug
  6. Modify › Stats
  7. Modify › Search
  8. A results API
  9. Where this leads
Start lesson
6The same API in FastAPI OptionalNot started

A database behind the app

An optional extension: keep the members in a SQLite database instead of a file (do the SQL course lessons 1 to 8 first).

7Keep the club in a database OptionalNot started

Move the club's members from a CSV file into a SQLite database, so the app asks for exactly the rows it needs.

  1. Predict
  2. Run
  3. Investigate › The missing line
  4. Investigate › Passing the values
  5. Modify
  6. Make
Start lesson

Progress is saved in this browser only. Nothing is sent anywhere.

For teachers: Teacher guide (notes, answers, solutions, slides and worksheets)