StaffCoder
Flask

Flask Backend Development Exercises

Flask 3.1Python 3.13
3 modules · 4 challengesSign up
Module 1 of 3 · 4 challenges

Routing & Views

Map URLs to views the Flask way: typed converters that reject bad addresses at routing, method-scoped endpoints, path captures and trailing-slash rules, and links built with url_for so they survive URL changes.
Finish every challenge, or complete the star challenge, to complete the module.

Challenges

4 challenges

Typed Route Converters

Sign up to unlock
100%1 of 1 solvedeasy
About this challenge

Item, user and price URLs in a small catalog service accept any value, so a bad address reaches the view and crashes it. Declare each route with the right typed converter so Flask converts integers, decimals and plain strings during routing, hands the view an argument that already has the right type, and rejects malformed addresses with a 404 before any view code runs.

Solved in a browser IDE and graded by tests. Sign up to solve

Methods And URL Building

Sign up to unlock
—No data yeteasy
About this challenge

A notes app answers every HTTP method on its list page, and its templates hardcode each link, so any URL change breaks navigation. Limit each route to the methods it supports so GET and POST do different work and other methods get 405. Then build every internal link and form action with url_for, including route arguments and query parameters, so the links keep working when a rule moves.

Solved in a browser IDE and graded by tests. Sign up to solve

Path Variants And Redirect Rules

Sign up to unlock
—No data yeteasy
About this challenge

A documentation site needs pages addressed by nested paths of any depth, and its about and contact pages treat trailing slashes inconsistently. Serve the nested page tree from one route that captures the full remaining path with its slashes intact. Make each page follow Flask's trailing-slash rules: a slashed route redirects its unslashed form to the canonical URL, and an unslashed route answers its slashed form with a 404.

Solved in a browser IDE and graded by tests. Sign up to solve

Wiki Route Surface

STAR
Solving it completes the module
—No data yeteasy
About this challenge

Build the complete routing table for a wiki: articles with integer ids, revisions with decimal versions, author handles, and a page tree addressed by nested paths. Viewing and editing an article are separate methods on one URL, slashed and unslashed pages follow the canonical redirect rules, and every navigation link is built with url_for, so the whole wiki still works when it is mounted under a different prefix.

Solved in a browser IDE and graded by tests. Sign up to solve

About this path

Build web applications with Flask, from routing and request handling through templates, sessions, blueprints, application factories, middleware, streaming and security hardening.

Frequently asked questions

4

What will I practice in this path?

3 modules: Routing & Views, Request Data Handling and Responses, Redirects & Status Codes.

How many Flask exercises are there, and how hard are they?

4 exercises, all easy.

What does this path run on?

Challenges run on Flask 3.1 and Python 3.13.

Do I need to install anything?

No. Every challenge runs in a browser-based IDE with everything already set up, and your code is graded automatically against a test suite.

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.