Registry / web-framework / routes

routes

JSON →
library2.5.1pypypi✓ verified 24d ago

Routes is a Python library that re-implements the Rails routing system, enabling developers to map URLs to application actions and generate URLs. It focuses on creating clean, concise, and RESTful URLs with features like named routes, conditional matching, and sub-domain support. The library is currently in maintenance mode, meaning active development is limited, but bug fixes via pull requests are still accepted. The latest stable version is 2.5.1.

pip install routes
INSTALL
IMPORT
SIG · ROUTES
R
routes
web-frameworkpythonv2.5.1
Install
1.6s avg
Import
24ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.5.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.026s · 18.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.022s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Mapper
from routes import Mapper
The primary class for defining and managing routes.
middleware
from routes import middleware
Provides WSGI middleware for integration.

This quickstart demonstrates how to initialize a `Mapper`, connect routes using placeholders and default values, and then match incoming URLs to retrieve controller/action parameters or generate URLs from parameters.

from routes import Mapper # Setup a mapper map = Mapper() # Connect routes map.connect(None, '/error/{action}/{id}', controller='error') map.connect('home', '/', controller='main', action='index') # Match a URL result = map.match('/error/myapp/4') print(f"Match result for '/error/myapp/4': {result}") result_home = map.match('/') print(f"Match result for '/': {result_home}") # Generate a URL url = map.generate(controller='main', action='index') print(f"Generated URL for main index: {url}") error_url = map.generate(controller='error', action='display', id=123) print(f"Generated URL for error: {error_url}")
Debug
Known issues
deprecatedRoutes is in maintenance mode. While bug reports are accepted and pull requests with tests will be applied, active feature development is unlikely. Consider this when planning long-term projects or expecting new features.
fix
Be aware of the library's maintenance status. For new projects requiring active development or extensive new features in routing, evaluate more actively maintained alternatives. Continue to use `routes` if its current feature set meets your needs and you are comfortable with community-driven bug fixes.
affects: 2.5.1 and newer
breakingVersions prior to 2.5.0 had specific Python version requirements. Support for Python 2.6, 3.3, and 3.4 was removed in 2.5.0.
fix
Ensure your project uses Python 3.5 or newer when using `routes` version 2.5.0 or later. For older Python versions, you would need to pin an older `routes` release, though this is not recommended due to lack of support.
affects: < 2.5.0
gotchaOlder versions (prior to 2.1) had issues with URL generation and caching, particularly when `SCRIPT_NAME` was involved or with specific parameter passing (e.g., 'host', 'protocol', 'anchor').
fix
Upgrade to `routes` 2.1 or higher to benefit from fixes related to URL generation and caching. If stuck on an older version, thoroughly test URL generation scenarios, especially those involving `SCRIPT_NAME` or custom host/protocol parameters.
affects: < 2.1
breakingIn version 1.9, the `Mapper` object's `hardcode_names` argument defaulted to `True`. This means routes generated by name must strictly adhere to the URL pattern.
fix
If migrating from versions prior to 1.9, be aware that named route generation will be more rigid by default. If flexible generation is needed, explicitly set `hardcode_names=False` when initializing the `Mapper`.
affects: 1.9 - 2.x
Upgrade
Version history
2.5.1latest on PyPI · released Oct 14, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
31 hits · last 30 days
node
26
Amazon
1
OpenAI (training)
1
Resources
routes — pip install routes · libregistry