Last active
September 25, 2024 10:06
-
-
Save intellectronica/e887914d5015da94e00926691d29453e to your computer and use it in GitHub Desktop.
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 * | |
app, rt = fast_app() | |
@app.get("/showtime") | |
def showtime(): | |
return Script("document.getElementById('time').innerText = (new Date()).toLocaleTimeString();" id='showtimescript') | |
@app.get("/") | |
def home(): | |
return ( | |
Div(id='time'), | |
Script(id='showtimescript'), | |
Button('Show Time', hx_get='/showtime', hx_swap='outerHTML', hx_target='#showtimescript'), | |
) | |
serve() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment