Metadata-Version: 2.4
Name: fhadmin
Version: 0.0.2
Summary: A lightweight, customizable admin panel for FastHTML applications with SQLite databases.
Author-email: Marius Vach <mariusvach@gmail.com>
License: Apache-2.0
Project-URL: Repository, https://github.com/vacmar01/fhadmin
Project-URL: Documentation, https://vacmar01.github.io/fhadmin
Keywords: nbdev,jupyter,notebook,python
Classifier: Natural Language :: English
Classifier: Intended Audience :: Developers
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: python-fasthtml
Requires-Dist: fhdaisy
Requires-Dist: fh-heroicons
Dynamic: license-file

# fhadmin


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

A lightweight, customizable admin panel for FastHTML applications with
SQLite databases.

## Features

- 🔐 Simple password authentication
- 📊 Table browser with card-based overview
- 🔍 Full-text search across text columns
- ✏️ Inline cell editing
- ➕ Create new records via modal
- 🗑️ Delete records
- 💻 SQL console for custom queries
- ⚠️ Dangerous SQL query detection with confirmation prompts
- 📄 Pagination with smart page buttons
- 🎨 Beautiful UI with DaisyUI/Tailwind

## Installation

``` bash
pip install fhadmin
```

## Quick Start

``` python
from fasthtml.common import *
from fhadmin.core import AdminConfig, create_admin
from fastlite import database

# Create your main app
app = FastHTML()

# Configure and mount the admin panel
cfg = AdminConfig(db_path="data/mydata.sqlite", password="secret")
admin_app = create_admin(cfg)
app.mount("/admin", admin_app)
```

Visit `/admin/login` to access the admin panel.

## Configuration

The
[`AdminConfig`](https://vacmar01.github.io/fhadmin/core.html#adminconfig)
dataclass accepts:

| Parameter  | Type          | Default      | Description                  |
|------------|---------------|--------------|------------------------------|
| `db_path`  | `str \| Path` | *required*   | Path to SQLite database file |
| `password` | `str`         | `"admin123"` | Admin login password         |

## How It Works

fhadmin uses a configuration-based architecture that stores settings in
`app.state.cfg`. Routes read the configuration at request time, making
it:

- **Notebook-friendly** — Rerun any route cell without side effects
- **Easy to debug** — Routes are plain functions, no closures
- **Flexible** — Change database or password at runtime if needed

## Routes

| Route | Method | Description |
|----|----|----|
| `/login` | GET/POST | Authentication |
| `/logout` | POST | End session |
| `/tables` | GET | Table overview cards |
| `/tables/{tbl}` | GET | Browse table with search & pagination |
| `/tables/{tbl}/new` | GET/POST | Create new record |
| `/tables/{tbl}/{pk}` | DELETE | Delete record |
| `/tables/{tbl}/{pk}/edit/{col}` | GET/PUT | Inline cell editing |
| `/tables/{tbl}/sql` | POST | Execute SQL query |
| `/tables/{tbl}/sql/confirm` | POST | Confirm dangerous SQL queries |

## Requirements

- Python 3.10+
- fasthtml
- fastlite
- fhdaisy
- fh-heroicons

## License

MIT
