Skip to main content

a custom-flask like basic web server module.

Project description

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

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

Installation

Install the package directly from your local repository root:

pip install .

To install in editable/development mode:

pip install -e .

Quick Start

1. Create your Template File (index.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

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:

[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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aserver-0.1.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aserver-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file aserver-0.1.0.tar.gz.

File metadata

  • Download URL: aserver-0.1.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for aserver-0.1.0.tar.gz
Algorithm Hash digest
SHA256 10878131b05d87946030b8194bdb481f818ea7a2df97198fafd1ef03cecac00d
MD5 d4db3651b8c68979abadd6390cb00eb3
BLAKE2b-256 afa6b41a1becf23294cb3c4de46d28a03cc844b2db61c058a50c5e018622e75f

See more details on using hashes here.

File details

Details for the file aserver-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: aserver-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for aserver-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c23c4190c17bf4c57cbaab58ad0e40030074edf9d927dacd0e50995a95a5d6a
MD5 2b5293aaed5331af1f9f1097ddb5c370
BLAKE2b-256 05b7c30da6246aae9ab7f349aa46e09aab7e69f64e583ef52a68300dacd62034

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page