Skip to content

Instantly share code, notes, and snippets.

View dgwyer's full-sized avatar
🏠
Working from home

David Gwyer dgwyer

🏠
Working from home
View GitHub Profile
@dgwyer
dgwyer / main.py
Created February 25, 2025 18:23
Todo Pagination
from fasthtml.common import *
from datetime import datetime
def render(todo):
show = AX(todo.title, f'/todos/{todo.id}', 'current-todo')
edit = AX('edit', f'/edit/{todo.id}' , 'current-todo')
dt = ' (done)' if todo.done else ''
return Li(show, dt, ' | ', edit, id=f'todo-{todo.id}')
app,rt,todos,Todo = fast_app('data/todos.db', render, id=int, title=str, done=bool, pk='id', live=True)
@dgwyer
dgwyer / main.py
Created March 7, 2025 09:48
FastHTML Context Menu
from fasthtml.common import *
app,rt = fast_app(live=True)
@rt("/")
def get():
menu_css = Style("""
.context-menu {
display: none;
position: absolute;
@dgwyer
dgwyer / wp_mcp_server.py
Last active April 16, 2025 14:45
Basic WP MCP Server
from mcp.server.fastmcp import FastMCP
import httpx
import base64
import asyncio
import os
from dotenv import load_dotenv
# Load env vars
load_dotenv()