Skip to content

Deufel/todo

Repository files navigation

todo

This file will become your README and also the index of your documentation.

FastHTML Todo Application Guide

A guide to using the Todo application with nbdev and FastHTML

Introduction

This is a simple Todo application built with FastHTML and nbdev. It demonstrates how to structure a FastHTML application using nbdev’s notebook-based development approach.

Getting Started

To run the application:

Copy from app import run_app

run_app()

Project Structure

This project is organized into several modules:

  • core: Core utilities and configurations
  • db: Database models and operations
  • components: UI components for rendering Todos
  • auth: Authentication functionality
  • todos: Todo management routes
  • app: Main application assembly

Features

  • User authentication
  • Create, read, update, and delete Todos
  • Drag and drop reordering of Todos
  • Markdown support in Todo details

Database Schema

The application uses SQLite with FastLite, which supports the MiniDataAPI spec:

Copy from db import db, Todo, User

Database tables print(f”Tables: {list(db.t.keys())}“)

Todo schema print(f”Todo fields: {Todo.annotations}“)

Authentication

Authentication is handled with session-based auth and Beforeware:

Copy from auth import before, login_redir

The beforeware checks if a user is authenticated and redirects to login if not

Todo Management

The main functionality is in the todos module:

Copy from todos import todo_routes

Routes include: GET / - Main todo list POST / - Create new todo PUT / - Update todo DELETE /todos/{id} - Delete todo GET /todos/{id} - View todo details GET /edit/{id} - Edit todo form

Extending the Application

To add new features, create a new notebook with appropriate routes and import it in app.ipynb.

Deployment

To deploy this application:

  1. Export the nbdev project
  2. Run the main app module
nbdev_export python -m todo_app.app