Jupyter Extension
Serve your app
and displaying in the notebook.
The line magic can be used multiple times in the notebook, making it a great tool for iterative development.
%load_ext fh_utils
%fh app [--page PAGE] [-w WIDTH] [-h HEIGHT] [-p PORT] app
Example
from fasthtml.common import Title, Main, H1, P, Button, fast_app
= fast_app()
app, rt = 0
count
@rt("/")
def home():
return Title("Count Demo"), Main(
"Count Demo"),
H1(f"Count is set to {count}", id="count"),
P("Increment", hx_post="/increment", hx_target="#count", hx_swap="innerHTML"),
Button(
)@rt
def increment():
global count
+= 1
count return f"Count is set to {count}"
%load_ext fh_utils
%fh app
The line magic can be used multiple time in the notebook
print("Current count is", count) # new value
= 1234
count %fh app