From ca5aa70fe9864dac54e4920be1ed1fa1544cd66a Mon Sep 17 00:00:00 2001 From: Charles Frye Date: Wed, 11 Sep 2024 15:50:56 -0700 Subject: [PATCH] adds a very simple fastHTML example (#873) --- 07_web_endpoints/fasthtml_app.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 07_web_endpoints/fasthtml_app.py diff --git a/07_web_endpoints/fasthtml_app.py b/07_web_endpoints/fasthtml_app.py new file mode 100644 index 000000000..9c2c9c7cf --- /dev/null +++ b/07_web_endpoints/fasthtml_app.py @@ -0,0 +1,25 @@ +# --- +# deploy: true +# cmd: ["modal", "serve", "07_web_endpoints/fasthtml_app.py"] +# --- +import modal + +app = modal.App("example-fasthtml") + + +@app.function( + image=modal.Image.debian_slim(python_version="3.12").pip_install( + "python-fasthtml==0.5.2" + ) +) +@modal.asgi_app() # must define a function decorated with asgi_app and app.function that returns your fastHTML app +def serve(): + import fasthtml.common as fh + + app = fh.FastHTML() + + @app.get("/") + def home(): + return fh.Div(fh.P("Hello World!"), hx_get="/change") + + return app