Skip to content

Instantly share code, notes, and snippets.

from fasthtml.common import *
app,rt = fast_app(debug=True)
db = database(":memory:")
clients = db.t.clients
if clients not in db.t:
clients.create(id=int,name=str,address=str,email=str,pk='id')
Client = clients.dataclass()
def create_form():
return Form(id="create-form", hx_post="/", hx_target="#client-list", hx_swap="beforeend")
def create_row():
@pitvfx
pitvfx / dynamic_table_main.py
Last active September 9, 2024 07:39
A simple, dynamic Web App CRUD Table for FastHTML
from fasthtml.common import *
app, rt = fast_app(debug=True)
db = database(":memory:")
clients = db.t.clients
if clients not in db.t:
clients.create(id=int, name=str, address=str, email=str, pk='id')
import os
import sys
import argparse
from fasthtml.components import html2ft
def main():
# Set up the argument parser
parser = argparse.ArgumentParser(description='Process an HTML file and output a Python file.')
parser.add_argument('filename', help='The name of the HTML file (without extension) located in the src folder.')
parser.add_argument('--output-dir', default='.', help='Optional output directory for the .py file (default is root).')
@pitvfx
pitvfx / create_django.bat
Last active August 19, 2024 13:34
error fixes
@echo off
REM Check if pyenv is installed, else exit with an error message
where /q pyenv >nul 2>nul
if %errorlevel% neq 0 (
echo Error: pyenv is not installed. Please install pyenv and try again.
exit /b 1
)
REM Check if pipenv is installed, else exit with an error message
@pitvfx
pitvfx / create_django.sh
Created October 7, 2023 22:45
linux django start up script
#!/bin/bash
# Check if pyenv is installed, else exit with an error message
if ! command -v pyenv &> /dev/null; then
echo "Error: pyenv is not installed. Please install pyenv and try again."
exit 1
fi
# Check if pipenv is installed, else exit with an error message
if ! command -v pipenv &> /dev/null; then