Skip to content

Examples

Worked examples — each page is one real problem, the awkward way to solve it without URLPattern, and the URLPattern-shaped replacement. Every snippet has been verified against the test suite.

Web routing

Security

AI / model serving

Text + data pipelines


Every example follows the same shape:

  1. The problem — what someone is actually trying to do, with a real public reference (issue link, blog post, framework doc).
  2. The awkward way — typical Python today: urlparse + if host == … ladders, hand-rolled regex, or framework-specific config gymnastics.
  3. With URLPattern — one declarative pattern, structured match result.
  4. What you get for free — which URLPattern feature carried the weight (cross-component matching, optional segments, named groups with regex, compare_component(), custom-scheme support, …).