Skip to content

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

License

Notifications You must be signed in to change notification settings

vacmar01/fhadmin

Repository files navigation

fhadmin

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

pip install fhadmin

Quick Start

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •