from fasthtml import serve
from fasthtml.components import *

from myfasthtml.controls.helpers import mk
from myfasthtml.core.commands import Command
from myfasthtml.icons.fa import icon_home
from myfasthtml.myfastapp import create_app

app, rt = create_app(protect_routes=False)


def change_text():
  return "New text"


command = Command("change_text", "change the text", change_text).htmx(target="#text")


@rt("/")
def index():
  return mk.button(Div(mk.icon(icon_home), Div("Hello World", id="text"), cls="flex"), command=command)


if __name__ == "__main__":
  serve(port=5002)
