Skip to content

Commit

Permalink
starter.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed Aug 13, 2024
1 parent d7d3eec commit bdd4cc2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
16 changes: 16 additions & 0 deletions helloworld/starter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from random import random
from fasthtml.common import *
app,rt = fast_app()

@rt
def index():
return Titled(
'Hello',
Div(P('click'), post=rnd)
)

@rt
def rnd(): return P(random())

serve()

19 changes: 15 additions & 4 deletions htmx/surreal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@
@rt("/")
def get():
return Titled('Hello',
H2("fadeOut() Demo"),
Safe('I fade <i>out</i> and <i>remove</i> my italics.'),
Any('await sleep(1000); e.fadeOut()', 'i'),
Div('Click me to remove me.', On('e.fadeOut()')),
Any('i', 'await sleep(1000); e.fadeOut()'),
Button('Click me to remove me.', On('e.fadeOut()')),
Div('I am leaving soon!'),
Prev('await sleep(1000); e.fadeOut()')
H2("On() Demo"),
Div("I change color when clicked.",
On("e.styles('background-color: lightblue');")
),
H2("AnyOn() Demo"),
Button("Button 1"),
Button("Button 2"),
Button("Button 3"),
AnyOn("button", "e.classToggle('highlight');"),
H2("Prev() Demo"),
Input(type="text", placeholder="Type here"),
Prev("e.value = e.value.toUpperCase();", event="input"),
Style(".highlight { background-color: yellow; }")
)

serve()

0 comments on commit bdd4cc2

Please sign in to comment.