Metadata-Version: 2.4
Name: velix
Version: 0.1.0
Summary: A lightweight, beginner-friendly Python web framework.
Author: Vasudev
License: MIT
Project-URL: Homepage, https://github.com/Along-the-skies/velix
Project-URL: Repository, https://github.com/Along-the-skies/velix
Keywords: web,framework,velix,lightweight,http,routing,templates
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# Velix 🚀

**Velix** is a lightweight, beginner-friendly Python web framework built entirely using Python's standard library with **zero external dependencies**.

---

## ✨ Features

- ⚡ **Lightweight & Fast**: Built from the ground up on Python standard library (`http.server`).
- 🛣️ **Simple & Intuitive Routing**: Supports `@app.get()`, `@app.post()`, `@app.put()`, `@app.delete()`, `@app.patch()`.
- 🔀 **Dynamic Route Parameters**: Easy `<param_name>` URL parameter matching (e.g. `/user/<name>`).
- 📥 **Request System**: Access `request.query`, `request.headers`, `request.cookies`, `request.json()`, `request.form`, and `request.files`.
- 📤 **Response System**: Send HTML, raw bytes, JSON (`json_response(...)`), redirects (`redirect(...)`), and custom cookies (`set_cookie(...)`).
- 🎨 **HTML Template Engine**: `render("index.html", key=value)` with variable replacement and template inheritance (`{% extends "base.html" %}`, `{% block content %}`).
- 🛠️ **CLI Tooling & Auto-reload**: Quick project scaffolding with `velix create <project_name>` and auto-reloading dev server with `velix startserver --reload` (or `velix app startserver`).
- 📂 **Static File Support**: Automatically serves static files (CSS, JS, images) from `/static/`.
- 🐛 **Debug Mode**: Interactive HTML stack traces on 500 errors during development (`App(debug=True)`).
- 🧠 **Clean Identity**: Simple `control.py` architecture for controllers and routing handlers.

---

## 📦 Installation

```bash
pip install velix
```

---

## 🚀 Quickstart

### 1. Create a New Project

```bash
velix create my_app
cd my_app
```

This generates a clean project layout:
```text
my_app/
├── app.py
├── control.py
├── templates/
│   └── index.html
└── static/
    └── style.css
```

### 2. Run the Development Server

```bash
velix startserver --reload
```
or:
```bash
velix app startserver --reload
```

Open `http://127.0.0.1:8000` in your browser!

---

## 💻 Code Examples

### `app.py`
```python
from velix import App
from control import register_routes

app = App(debug=True)
register_routes(app)

if __name__ == "__main__":
    app.run(host="127.0.0.1", port=8000)
```

### `control.py`
```python
from velix import render, json_response, redirect, Response

def register_routes(app):

    @app.get("/")
    def home():
        return render("index.html", title="Welcome to Velix")

    @app.get("/hello/<name>")
    def greet(request, name):
        lang = request.query.get("lang", "en")
        if lang == "es":
            return f"Hola {name}!"
        return f"Hello {name}!"

    @app.post("/api/user")
    def create_user(request):
        data = request.json()
        username = data.get("username")
        return json_response({"message": f"User {username} created!"}, status_code=201)

    @app.get("/login")
    def login_page():
        res = Response.html("<h1>Login Page</h1>")
        res.set_cookie("session_id", "secret123", max_age=3600)
        return res
```

---

## 🎨 Template Inheritance

### `templates/base.html`
```html
<!DOCTYPE html>
<html>
<head>
    <title>{% block title %}Velix App{% endblock %}</title>
</head>
<body>
    <header><h1>My Site</h1></header>
    <main>
        {% block content %}{% endblock %}
    </main>
</body>
</html>
```

### `templates/child.html`
```html
{% extends "base.html" %}

{% block title %}Dashboard{% endblock %}

{% block content %}
<h2>Hello {{ user.name }}!</h2>
<p>Welcome to your dashboard.</p>
{% endblock %}
```

---

## 📄 License

MIT License. Built with ❤️ for Python developers.
