nolite 0.1.1
A Python library to create websites using only Python code
Requires Python: >=3.6

# Nolite: The Full-Stack Python Web Framework

[![PyPI version](https://badge.fury.io/py/nolite.svg)](https://badge.fury.io/py/nolite)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Build Status](https://img.shields.io/badge/build-passing-brightgreen)](https://github.com/FakeCoder01/nolite)

**Build beautiful, database-driven web applications using only Python**

Nolite is a full-stack web framework for Python developers who want to create robust web applications without the steep learning curve of modern frontend development or complex backend configurations. Our mission is to provide an intuitive, batteries-included, and purely Pythonic way to build for the web.

### [READ THE DOCS](docs/)

---

## Key Features

- **Truly Full-Stack:** From frontend rendering to backend logic and database management, Nolite provides a single, unified Python environment.
- **Pythonic Styling:** Style your UI components using simple Python keyword arguments. Nolite translates `bg_color="blue"` into the correct CSS, so you don't have to.
- **Database Included:** Built-in integration with SQLAlchemy and SQLite gets you started with a powerful ORM and a zero-config database from day one.
- **Component-Based UI:** Build your user interface with a rich library of components, from basic tags like `Div` to advanced, interactive elements like `Navbar` and `Slider`.
- **Command-Line Interface:** Nolite comes with a CLI to instantly generate a new, well-structured, full-stack project, so you can start developing immediately.
- **Powered by Flask:** Nolite is built on the solid foundation of Flask, giving you access to its powerful ecosystem and extensions. It works seamlessly with standard Flask features like Blueprints.

---

## Quick Start: Your First Nolite Project in 60 Seconds

Nolite's Command-Line Interface (CLI) is the fastest and recommended way to start a new project.

### 1. Installation

First, install Nolite from PyPI. This will also make the `nolite` CLI tool available.

```bash
pip install nolite
```

### 2. Create a New Application

Use the `python -m nolite new` command to generate a new, full-stack project. This creates a new directory with a complete, ready-to-run application.

```bash
python -m nolite new my-first-app
```

### 3. Run the Development Server

Navigate into your new project directory and run the application.

```bash
cd my-first-app
python run.py
```

Your new Nolite application is now running at **http://127.0.0.1:5000**.

When you open your browser, you will see a welcome page that is dynamically rendering content from a pre-configured SQLite database. You have just created and launched a full-stack web application!

---

## The Nolite Workflow: A Glimpse Inside

The project generated by `nolite new` has a clean, scalable structure:

```text
my-first-app/
├── app.db            # Your application's SQLite database file
├── run.py            # The main entry point to start the server
└── app/
    ├── __init__.py   # Initializes the app, database, and routes
    ├── layout.py     # Defines a reusable page layout
    ├── models.py     # Defines your database tables (e.g., User)
    └── routes.py     # Defines your application's pages and logic
```

### 1. Define Your UI with Components

Build your pages by composing components and styling them with simple keyword arguments.

```python
# app/layout.py
from nolite.components import Card, H1, Paragraph

def info_card(title, text):
    return Card(
        padding=25,
        border_radius=8,
        box_shadow="0 5px 15px rgba(0,0,0,0.1)",
        hover_style={"transform": "translateY(-5px)"},
        transition="transform 0.2s ease-in-out",
        children=[
            H1(children=[title]),
            Paragraph(children=[text])
        ]
    )
```

### 2. Define Your Database in `models.py`

Create your database tables by defining simple Python classes. Nolite handles the SQL for you.

```python
# app/models.py
from . import db

class Product(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(120), nullable=False)
    price = db.Column(db.Float, nullable=False)
```

### 3. Create Your Pages in `routes.py`

Define a function that returns a `Page` object and decorate it with a route. You can query your database directly inside this function.

```python
# app/routes.py
from . import app
from .models import Product
from .layout import main_layout

@app.route("/")
def index():
    # Query the database for all products
    all_products = Product.query.all()

    # Use your components to build the page content
    product_cards = [info_card(p.name, f"${p.price}") for p in all_products]

    # Return the final page using your main layout
    return main_layout(children=product_cards)
```

## Contributing

Any contribution of all kinds is welcome. Whether it's reporting a bug, suggesting a new feature, or improving the documentation.

## License

This project is licensed under the MIT License.