Metadata-Version: 2.4
Name: py-flexo
Version: 0.2.2
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: requests-wsgi-adapter>=0.4.1
Requires-Dist: webob>=1.8.10
Requires-Dist: whitenoise>=6.12.0

# PyFlexo

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

<p align="center">

![Python](https://img.shields.io/badge/python-3.10%2B-blue)
![License](https://img.shields.io/badge/license-MIT-green)
![Tests](https://img.shields.io/badge/tests-passing-success)
![Version](https://img.shields.io/badge/version-0.2.1-orange)

</p>

---

# Why PyFlexo?

PyFlexo is a lightweight WSGI web framework focused on simplicity, readability, and extensibility.

Instead of hiding how web applications work, PyFlexo provides a clean API while remaining close to the WSGI specification.

It is suitable for:

- Learning web framework internals
- Small web applications
- REST APIs
- Custom Python services


---

# Features

* Simple and intuitive routing
* Function-based views
* Class-based views
* Dynamic URL parameters
* Built-in template rendering with Jinja2
* Static file serving
* JSON response helper
* Global exception handlers
* Middleware support
* Lightweight ORM
* Pure Python implementation
* WSGI compatible
* Easy to extend


---

# Installation


## Using pip

```bash
pip install py_flexo
```


## Using uv

```bash
uv add py_flexo
```


---

# Quick Start


Create:

```
main.py
```


Add:


```python
from py_flexo.app import PyFlexoApp


app = PyFlexoApp()


@app.route("/")
def home(request, response):
    response.text = "Hello, PyFlexo!"
```


Run:


```bash
gunicorn main:app
```


---

# Documentation


PyFlexo documentation is organized by components.


## Core


Documentation includes:


- Routing
- Requests
- Responses
- Templates
- Middleware
- Exception handling
- Static files


## ORM


PyFlexo includes a lightweight ORM for database operations.


> ORM is available starting from **PyFlexo 0.2.0+**.


ORM documentation:


[PyFlexo ORM Documentation](docs/orm/README.md)


---

# Routing


## Function Based Views


```python
@app.route("/")
def index(request, response):
    response.text = "Hello World"
```


---

## Route Parameters


```python
@app.route("/hello/{name}")
def hello(request, response, name):
    response.text = f"Hello {name}"
```


Example:


```
GET /hello/Alice
```


Response:


```
Hello Alice
```


---

## Class Based Views


```python
@app.route("/books")
class Book:

    def get(self, request, response):
        response.text = "Book List"


    def post(self, request, response):
        response.text = "Create Book"
```


Supported methods:


- GET
- POST
- PUT
- PATCH
- DELETE


---

# Templates


PyFlexo supports Jinja2 templates.


Example:


```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.1"
    }
```


---

# Middleware


Example:


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


Example:


```python
def exception_handler(request, response, exception):

    response.status_code = 500
    response.text = "Internal Server Error"


app.add_exception_handler(exception_handler)
```


---

# Static Files


Project:


```
project/

    static/

        style.css
        app.js
        logo.png
```


Available:


```
/static/
```


Example:


```
/static/style.css
```


---

# Project Structure


Example:


```
project/

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


---

# Examples


Examples:


```
examples/
```


Includes:


- Basic application
- Routing examples
- ORM examples


---

# Roadmap


Future improvements:


* ORM improvements
* Database migrations
* Query filtering
* Cookies
* Sessions
* Authentication
* Blueprint support
* 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
