This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from fasthtml.common import * | |
| from fastlite import Database, Model, Field | |
| from dataclasses import dataclass, fields | |
| from typing import Optional | |
| import sqlite3 | |
| # Initialize FastHTML app with Tailwind CSS for styling | |
| app = FastHTML(hdrs=(picolink, Script(src="https://cdn.tailwindcss.com"))) | |
| # Initialize FastLite database |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from fasthtml.common import * | |
| from fastlite import * | |
| from dataclasses import dataclass | |
| from typing import Optional | |
| # Initialize FastHTML app with PicoCSS and SQLite database | |
| db = database('data/users.db') | |
| app, rt = fast_app(pico=True) | |
| # Define User dataclass for form data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from enum import Enum | |
| from functools import singledispatch | |
| class Color(Enum): | |
| RED = 1 | |
| GREEN = 2 | |
| BLUE = 3 | |
| @singledispatch | |
| def process(color: Color, *args, **kwargs): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Responsive Layout</title> | |
| <style> | |
| body { | |
| margin: 0; | |
| padding: 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| List of elements | |
| Element Description Categories Parents† Children Attributes Interface | |
| a Hyperlink flow; phrasing*; interactive; palpable phrasing transparent* globals; href; target; download; ping; rel; hreflang; type; referrerpolicy HTMLAnchorElement | |
| abbr Abbreviation flow; phrasing; palpable phrasing phrasing globals HTMLElement | |
| address Contact information for a page or article element flow; palpable flow flow* globals HTMLElement | |
| area Hyperlink or dead area on an image map flow; phrasing phrasing* empty globals; alt; coords; shape; href; target; download; ping; rel; referrerpolicy HTMLAreaElement | |
| article Self-contained syndicatable or reusable composition flow; sectioning; palpable flow flow globals HTMLElement | |
| aside Sidebar for tangentially related content flow; sectioning; palpable flow flow globals HTMLElement | |
| audio Audio player flow; phrasing; embedded; interactive; palpable* phrasing source*; track*; transparent* globals; src; crossorigin; preload; autoplay; loop; muted; controls HTMLAudioElement |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "*": { | |
| "attributes": { | |
| "accesskey": { | |
| "experimental": false | |
| }, | |
| "anchor": { | |
| "experimental": true | |
| }, | |
| "autocapitalize": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import colorsys | |
| def hex_to_rgb(hex_color): | |
| # Remove the '#' if present | |
| hex_color = hex_color.lstrip('#') | |
| return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4)) | |
| def calculate_luminance(hex_color): | |
| # Convert hex to RGB | |
| r, g, b = hex_to_rgb(hex_color) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Drag and Drop with JS</title> | |
| <style> | |
| body { | |
| margin: 2em; | |
| font-family: 'arial'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>HTML5 Modal Dialog Example</title> | |
| <style> | |
| /* Modal styles */ | |
| .modal { | |
| display: none; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from math import log10 | |
| from typing import Sequence | |
| def print_numbered_list(items: Sequence, fmt='{num}. {item}') -> None: | |
| """Display as a numbered list where the items are left aligned. | |
| items: | |
| A list of printable items. | |
| fmt: |