Metadata-Version: 2.4
Name: routly
Version: 0.3.0
Summary: A lightweight, modern Python microframework for Web & REST APIs
Author-email: Abdulbosit Alijonov <me@alijonov.uz>
License: MIT
Project-URL: Homepage, https://github.com/AlijonovUz/routly
Project-URL: Documentation, https://routly.readthedocs.io/
Project-URL: Repository, https://github.com/AlijonovUz/routly.git
Project-URL: Issue Tracker, https://github.com/AlijonovUz/routly/issues
Project-URL: Changelog, https://github.com/AlijonovUz/routly/releases
Keywords: routly,web,framework,microframework,api,rest,routing,wsgi,jinja2,middleware
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: WebOb>=1.8.0
Requires-Dist: jinja2>=3.1.0
Requires-Dist: whitenoise>=6.0.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: gunicorn>=21.0.0; extra == "dev"
Dynamic: license-file

# Routly

<p align="center">
  <img src="https://raw.githubusercontent.com/AlijonovUz/routly/main/example/static/images/logo.png" alt="Routly Logo" width="140" />
</p>

<p align="center">
  <strong>A lightweight, modular, modern Python microframework for Web & REST APIs.</strong>
</p>

<p align="center">
  <a href="https://pypi.org/project/routly/"><img src="https://img.shields.io/pypi/v/routly.svg?color=blue&logo=pypi&logoColor=white" alt="PyPI version"></a>
  <a href="https://routly.readthedocs.io/"><img src="https://readthedocs.org/projects/routly/badge/?version=latest" alt="Documentation Status"></a>
  <a href="https://pypi.org/project/routly/"><img src="https://img.shields.io/pypi/pyversions/routly.svg?logo=python&logoColor=white" alt="Python Versions"></a>
  <a href="https://github.com/AlijonovUz/routly/actions"><img src="https://img.shields.io/github/actions/workflow/status/AlijonovUz/routly/pypi-push.yml?branch=production&label=tests" alt="Build Status"></a>
  <a href="https://github.com/AlijonovUz/routly/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a>
  <a href="https://github.com/AlijonovUz/routly"><img src="https://img.shields.io/github/stars/AlijonovUz/routly?style=flat&logo=github" alt="GitHub Stars"></a>
</p>

---

## 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

```bash
pip install routly
```

Or install with development dependencies:

```bash
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/`](https://github.com/AlijonovUz/routly/tree/main/example) directory.

To run the showcase application locally:

```bash
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:

```bash
pytest tests/
```

---

## License

Created by **Abdulbosit Alijonov**.  
Distributed under the MIT License.
