Metadata-Version: 2.4
Name: aserver
Version: 0.1.0
Summary: a custom-flask like basic web server module.
Author-email: aadisankar1 <aadisankar1001@gmail.com>
License: MIT
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.13
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# AServer

A fast, lightweight Python HTTP server featuring a built-in micro-Jinja template evaluation engine with zero third-party dependencies.

---

## Features

* **Custom Template Engine**: Native syntax supporting loops (`{% for %}`), conditionals (`{% if %}`), and dynamic variable interpolation (`{{ var }}`).
* **Resource Safe**: Handles files securely with context managers to prevent memory leaks.
* **Modern Packaging**: PyPA compliant layout ready for PyPI distribution.

---

## Project Layout

```text
AServer/
├── LICENSE
├── README.md
├── pyproject.toml
└── src/
    └── aserver/
        ├── __init__.py
        ├── renderer.py
        └── server.py
```

---

## Installation

Install the package directly from your local repository root:

```bash
pip install .
```

To install in editable/development mode:

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

---

## Quick Start

### 1. Create your Template File (`index.html`)

```html
<div class="container">
    <h1>Welcome, {{ username }}!</h1>
    
    {% if show_list %}
    <ul>
        {% for item in items %}
        <li><strong>Item:</strong> {{ item }}</li>
        {% endfor %}
    </ul>
    {% endif %}
</div>
```

### 2. Run the Server

```python
from aserver import ServerHTTP

# Define address, template path, and initial context variables
address = ('127.0.0.1', 8080)
template = 'index.html'
context_data = {
    "username": "Alice",
    "show_list": True,
    "items": ["Apples", "Guavas", "Cherries"]
}

# Initialize and start serving
server = ServerHTTP(address, template, data=context_data)
server.serve()
```

---

## Configuration

You can also control application settings natively through the `pyproject.toml` file under the custom tool namespace:

```toml
[tool.aserver.settings]
host = "127.0.0.1"
port = 8080
default_template = "index.html"

[tool.aserver.initial_data]
username = "Developer"
site_title = "AServer Web App"
```

---

## License

This project is licensed under the MIT License - see the LICENSE file for details.
