Metadata-Version: 2.4
Name: fhadmin
Version: 0.0.1
Summary: A lightweight, customizable admin panel for FastHTML applications with SQLite databases.
Home-page: https://github.com/vacmar01/fhadmin
Author: Marius Vach
Author-email: mariusvach@gmail.com
License: Apache Software License 2.0
Keywords: nbdev jupyter notebook python
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
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: License :: OSI Approved :: Apache Software License
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: python-fasthtml
Requires-Dist: fhdaisy
Requires-Dist: fh-heroicons
Provides-Extra: dev
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# 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
- 📄 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 custom SQL |

## Requirements

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

## License

MIT
