Metadata-Version: 2.4
Name: py-flexo
Version: 0.2.4
Summary: A lightweight and extensible WSGI web framework for Python
License: MIT
Keywords: wsgi,web,framework,python,orm
Requires-Python: >=3.12
Description-Content-Type: text/markdown
Requires-Dist: jinja2>=3.1.6
Requires-Dist: parse>=1.22.1
Requires-Dist: webob>=1.8.10
Requires-Dist: whitenoise>=6.12.0

# PyFlexo

<p align="center">
  A lightweight, extensible WSGI web framework for Python.
</p>

<p align="center">
  <a href="https://py-flexo-docs.readthedocs.io/en/latest/">Full documentation</a>
</p>

<p align="center">
  <img alt="Python" src="https://img.shields.io/badge/python-3.12%2B-blue">
  <img alt="License" src="https://img.shields.io/badge/license-MIT-green">
  <img alt="Tests" src="https://img.shields.io/badge/tests-passing-success">
  <img alt="Version" src="https://img.shields.io/badge/version-0.2.3-orange">
</p>

## Overview

PyFlexo is designed for developers who want a clean, minimal web framework without losing visibility into how the request/response cycle works. It stays close to WSGI, keeps the API approachable, and includes the pieces commonly needed to build real applications.

It is a good fit for:

- Learning how Python web frameworks work under the hood
- Building small to medium web applications
- Creating APIs and custom services
- Prototyping projects with a simple, explicit architecture

## Key Features

- Simple routing with dynamic URL parameters
- Function-based and class-based views
- Jinja2 template rendering
- JSON responses
- Static file serving
- Middleware support
- Global exception handling
- Lightweight ORM
- Pure Python implementation
- WSGI compatible

## Installation

Install from PyPI with `pip`:

```bash
pip install py-flexo
```

Or with `uv`:

```bash
uv add py-flexo
```

## Quick Start

Create a `main.py` file:

```python
from py_flexo.app import PyFlexoApp


app = PyFlexoApp()

## Contributing

Contributions are welcome. Please open an issue before submitting large changes.

## License

MIT License

```python
@app.route("/home")
def home(request, response):
    response.html = app.template(
        "home.html",
        context={
            "title": "PyFlexo",
            "header": "Welcome",
        },
    )
```

### JSON Responses

```python
@app.route("/api")
def api(request, response):
    response.json = {
        "framework": "PyFlexo",
        "version": "0.2.3",
    }
```

### Middleware

```python
from py_flexo.middleware import Middleware


class LoggingMiddleware(Middleware):
    def process_request(self, request):
        print(request.method, request.path)

    def process_response(self, response):
        print(response.status_code)


app.add_middleware(LoggingMiddleware)
```

### Exception Handling

```python
def exception_handler(request, response, exception):
    response.status_code = 500
    response.text = "Internal Server Error"


app.add_exception_handler(exception_handler)
```

## ORM

PyFlexo includes a lightweight ORM for database operations. ORM support is available starting from PyFlexo 0.2.0.

For ORM-specific usage and examples, see the [full documentation](https://py-flexo-docs.readthedocs.io/en/latest/).

## Project Structure

```text
project/
├── main.py
├── templates/
│   └── home.html
├── static/
│   ├── style.css
│   └── app.js
├── database.db
└── pyproject.toml
```

## Roadmap

Future improvements may include:

- ORM improvements
- Database migrations
- Query filtering
- Cookies and sessions
- Authentication
- Blueprint support

## Documentation

Read the complete documentation here:

https://py-flexo-docs.readthedocs.io/en/latest/
* Request validation
* CLI
* Dependency Injection
* OpenAPI
* ASGI support
* WebSocket support


---

# Contributing


Contributions are welcome.


Please open an issue before submitting large changes.


---

# Author


PyFlexo is an open-source project created for developers who enjoy building fast and elegant Python web applications.


---

# License


MIT License
