Metadata-Version: 2.4
Name: routly
Version: 0.1.0
Summary: A lightweight, modern Python microframework for Web & REST APIs
Author: Abdulbosit Alijonov
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: WebOb>=1.8.0
Requires-Dist: parse>=1.20.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"

# Routly

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

Built from scratch with zero bloat, native WSGI compliance, and a developer-first design.

---

## Features

- **Fast & Expressive Routing:** Dynamic path matching with typed parameter extraction (`/users/{id}`).
- **First-Class REST API:** Automatic `dict` and `list` serialization to `application/json`, plus `(data, status_code)` return tuples.
- **Full REST Verbs:** Clean method decorators (`@app.get`, `@app.post`, `@app.put`, `@app.patch`, `@app.delete`).
- **Batteries-Included Middleware Pipeline:**
  - `CsrfMiddleware` (Double-submit cookie pattern)
  - `CorsMiddleware` (Preflight OPTIONS, customizable origins, methods, and credentials)
  - `SecurityMiddleware` (`ALLOWED_HOSTS`, clickjacking, XSS, and MIME-sniffing protection)
  - `SessionMiddleware` (Tamper-proof HMAC-SHA256 signed cookies)
  - `GZipMiddleware` (Automatic response body compression)
  - `ProcessTimeMiddleware` (Request execution timing in `X-Process-Time`)
- **HTTP Exception Hierarchy:** Django-inspired exceptions (`BadRequest`, `Unauthorized`, `Forbidden`, `NotFound`, `MethodNotAllowed`, `InternalServerError`, `abort(code, message)`).
- **Dark-Mode Debugger:** Tailwind CSS powered interactive traceback screen with request headers, client details, and traceback clipboard copy.
- **Content Negotiation:** Automatic JSON error responses for API consumers, interactive debugger for browser requests.
- **Jinja2 Templating:** Template inheritance with built-in `{{ static('...') }}` and `{{ csrf_input() }}` helpers.
- **Production Static Assets:** Native static file delivery powered by WhiteNoise.
- **Modular Settings:** Django-style configuration discovery via `ROUTLY_SETTINGS_MODULE` or `settings.py`.
- **100% WSGI Compliant:** Works seamlessly with Gunicorn, uWSGI, and any standard WSGI server.

---

## Installation

```bash
pip install -e .
```

---

## Quickstart

Create `app.py`:

```python
from routly import RoutlyApp

app = RoutlyApp()


@app.get("/")
def home(request):
    return app.template("index.html")


@app.get("/api/users/{id}")
def get_user(request, id):
    return {"id": id, "name": "Abdulbosit", "active": True}


@app.post("/api/users")
def create_user(request):
    return {"status": "created", "user": request.json}, 201
```

Run with Gunicorn:

```bash
gunicorn -b 127.0.0.1:8000 app:app
```

---

## Testing

Run the test suite with pytest:

```bash
pytest tests/
```

---

## License

Author: **Abdulbosit Alijonov**  
Open-source under the MIT License.
