Skip to content

Commit

Permalink
adds a very simple fastHTML example (#873)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesfrye authored Sep 11, 2024
1 parent 35851c4 commit ca5aa70
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions 07_web_endpoints/fasthtml_app.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ca5aa70

Please sign in to comment.