Skip to main content

Routly

Routly Logo

A lightweight, modular, modern Python microframework for Web & REST APIs.

PyPI version Documentation Status Python Versions Build Status License GitHub Stars


Overview

Routly is crafted for developers who desire the simplicity and elegance of modern microframeworks combined with enterprise-grade security and production WSGI reliability. It provides first-class REST API primitives, automatic content negotiation, double-submit CSRF defense, signed cookie sessions, and an interactive Tailwind CSS dark-mode debugger.


Key Features

  • Expressive & Typed Routing: Compiled regex path matching with typed converters (/users/{id:int}, float, slug, uuid, path), multi-method routes, per-router/route dependencies=[...], and modular Router(prefix=...) mounting via include_router.
  • Built-In CLI (routly): Scaffold projects (routly create), run an auto-reloading dev server (routly runserver --reload), inspect routes (routly routes), and generate secret keys (routly secretkey).
  • First-Class REST APIs & Streaming: Native serialization for Python dictionaries and lists to application/json, HTTP status tuples ({"ok": True}, 201), plus chunked StreamingResponse and FileResponse with MIME detection.
  • Dual-Mode Access Decorators: Protect routes via @login_required, @require_role, @require_permissions, @require_api_key, @require_https, or @rate_limit as decorators or router guards.
  • Standard HTTP Verbs: Intuitive decorators (@app.get, @app.post, @app.put, @app.patch, @app.delete, @app.route).
  • Lifecycle & Custom Error Handling: Thread-safe @app.on_startup / @app.on_shutdown hooks and @app.error_handler(...) for status codes or exception classes.
  • Modular Middleware Onion:
    • SecurityMiddleware: Domain whitelisting (ALLOWED_HOSTS), clickjacking defense (X-Frame-Options), MIME-sniffing prevention, and HSTS.
    • CsrfMiddleware: Double-submit cookie defense for state-changing HTTP methods.
    • SessionMiddleware: Tamper-proof, HMAC-SHA256 cryptographically signed cookies.
    • CorsMiddleware: Cross-Origin Resource Sharing with customizable origins and preflight handling.
    • GZipMiddleware: On-the-fly response payload compression (automatically skipping streaming responses).
    • ProcessTimeMiddleware: High-precision latency diagnostics in X-Process-Time.
    • LoggingMiddleware: Single-line structured console access logs with ANSI status colors and client IP tracking.
    • RateLimitMiddleware: Thread-safe sliding-window rate limiting with 429 TooManyRequests and Retry-After headers.
  • Intelligent Content Negotiation: API endpoints receive clean JSON errors, while browser clients get an interactive developer error screen.
  • Tailwind Dark-Mode Debugger: Visual traceback inspection with one-click clipboard copying and client headers display.
  • Integrated Templating & Media Uploads: Jinja2 rendering with {{ static(...) }}, {{ media(...) }}, and {{ csrf_input() }} helpers, plus request.files (UploadedFile) uploads and dynamic MEDIA_ROOT delivery.
  • Built-in Static Delivery: Seamless asset serving powered by WhiteNoise.
  • WSGI Standard: Deploy directly on Gunicorn, uWSGI, Granian, or Waitress.

Installation

pip install routly

Or install with development dependencies:

pip install "routly[dev]"

Example Project

A complete, production-grade example application featuring authentication, session management, CSRF protection, and REST API CRUD is available in the example/ directory.

To run the showcase application locally:

python example/main.py

Testing

Use the built-in routly.testing.TestClient for in-process endpoint testing with persistent cookies, JSON helpers, and redirect following, and run the test suite with pytest:

pytest tests/

License

Created by Abdulbosit Alijonov.
Distributed under the MIT License.

Metadata

Release files for routly 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for routly 0.3.0
File Size Uploaded Provenance Actions
routly-0.3.0.tar.gz 60.8 kB Without provenance Details for routly-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for routly 0.3.0
File Interpreter ABI Platform Actions
routly-0.3.0-py3-none-any.whl Python 3 none any Details for routly-0.3.0-py3-none-any.whl

Total release size: 113.3 kB

Release files / routly-0.3.0.tar.gz

Download URL routly-0.3.0.tar.gz
Size 60.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c884bb866cfadf6110388203d9f04d77687fc8087dc7c4d805a37dbc44c15987
BLAKE2b-256 checksum
How to use checksums
dca852c0ce0a8488817739b5594f8a09248748a8007a944e43a8ebcd9de6e754
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / routly-0.3.0-py3-none-any.whl

Download URL routly-0.3.0-py3-none-any.whl
Size 52.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db7a763c0aa3d8d6492971dc87ced226c1984de21cdd536746212cbd4b1262f5
BLAKE2b-256 checksum
How to use checksums
7c2a8ce689c085bfc08d7982c69ca3973d3a716c4c734aa780b60c508bd044c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for routly 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page