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 routesVerified import paths — ran on the pinned version, not inferred.
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.
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.
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.
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.
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`.
No dependency data recorded yet.