Skip to content

Starter template for FastHTML applications with plugins, workers, settings, and resource management built-in.

License

Notifications You must be signed in to change notification settings

cj-mills/fasthtml-app-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastHTML App Template

Starter template for FastHTML applications with plugins, workers, settings, and resource management built-in.

Features

  • Schema-driven Settings - Auto-generated settings UI from JSON schemas
  • Plugin System - Extensible plugin architecture
  • Background Workers - Long-running job processing (optional)
  • Resource Monitoring - CPU/GPU/memory tracking (optional)
  • DaisyUI Styling - Themed components
  • Minimal Boilerplate - Helper functions eliminate repetitive code

Quick Start

1. Install Dependencies

pip install -r requirements.txt

2. Run the App

python demo_app.py

The app will open in your browser at http://localhost:5000

3. Explore

  • Homepage (/): Overview and quick links
  • Settings (/settings): Configure app title, theme, server settings

Project Structure

fasthtml-app-template/
├── app
│   ├── core
│   │   ├── html_ids.py
│   │   ├── navbar.py
│   │   └── page_layout.py
│   ├── main
│   │   ├── components
│   │   │   └── homepage.py
│   │   └── routes.py
│   └── settings
│       ├── config.py
│       ├── schemas.py
│       └── utils.py
├── demo_app.py
└── requirements.txt

Customization Guide

Adding Custom Settings

Edit app/settings/schemas.py to add new settings:

MY_SCHEMA = {
    "name": "my_settings",
    "title": "My Settings",
    "type": "object",
    "properties": {
        "my_option": {
            "type": "string",
            "title": "My Option",
            "default": "default_value",
            "enum": ["option1", "option2", "option3"]
        }
    }
}
registry.register(MY_SCHEMA)

The settings UI is automatically generated and accessible at /settings.

Adding New Routes

  1. Create a new router:
# app/mymodule/routes.py
from fasthtml.common import *

mymodule_ar = APIRouter(prefix="/mymodule")

@mymodule_ar
def index():
    return Div("My Module")
  1. Register it in demo_app.py:
from app.mymodule.routes import mymodule_ar

register_routes(app, settings_ar, main_ar, mymodule_ar)

Customizing the Navbar

Edit app/core/navbar.py to modify navigation links:

nav_items = [
    ("Home", main_rt.home),
    ("My Page", mymodule_rt.index),
    ("Settings", settings_rt.index),
]

Changing Themes

Visit /settings to change themes in the UI, or modify the default in app/settings/schemas.py.

Enabling Plugins (Optional)

Uncomment the plugin system code in demo_app.py and customize:

from my_plugin_system.plugin_interface import MyPlugin

plugin_registry.register_plugin_system(
    category="my_category",
    plugin_interface=MyPlugin,
    display_name="My Plugins",
    auto_discover=True
)

Enabling Workers (Optional)

Uncomment the worker system code in demo_app.py to enable background job processing with resource management and SSE support.

Helper Functions

This template uses helper functions from the cjm-fasthtml libraries to minimize boilerplate:

  • configure_settings() - Configure settings system in one call
  • register_routes() - Register multiple routers at once
  • register_plugin_system() - Setup plugin systems in one step
  • create_standard_adapters() - Zero adapter boilerplate for workers

See the library documentation for detailed usage.

Libraries Used

Core Libraries

Optional Libraries

UI Libraries

Resources

About

Starter template for FastHTML applications with plugins, workers, settings, and resource management built-in.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages