Skip to content

Commit

Permalink
Add path arg to HTMX
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed Oct 8, 2024
1 parent 7e612c2 commit 80679ca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions fasthtml/jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def FastJupy(hdrs=None, middleware=None, **kwargs):
return FastHTML(hdrs=hdrs, middleware=middleware, **kwargs)

# %% ../nbs/api/06_jupyter.ipynb
def HTMX(host='localhost', port=8000, iframe_height="auto"):
def HTMX(path="", host='localhost', port=8000, iframe_height="auto"):
"An iframe which displays the HTMX application in a notebook."
return HTML(f'<iframe src="http://{host}:{port}" style="width: 100%; height: {iframe_height}; border: none;" ' + """onload="{
return HTML(f'<iframe src="http://{host}:{port}/{path}" style="width: 100%; height: {iframe_height}; border: none;" ' + """onload="{
let frame = this;
window.addEventListener('message', function(e) {
if (e.data.height) frame.style.height = (e.data.height+1) + 'px';
Expand Down
4 changes: 2 additions & 2 deletions nbs/api/06_jupyter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@
"outputs": [],
"source": [
"#| export\n",
"def HTMX(host='localhost', port=8000, iframe_height=\"auto\"):\n",
"def HTMX(path=\"\", host='localhost', port=8000, iframe_height=\"auto\"):\n",
" \"An iframe which displays the HTMX application in a notebook.\"\n",
" return HTML(f'<iframe src=\"http://{host}:{port}\" style=\"width: 100%; height: {iframe_height}; border: none;\" ' + \"\"\"onload=\"{\n",
" return HTML(f'<iframe src=\"http://{host}:{port}/{path}\" style=\"width: 100%; height: {iframe_height}; border: none;\" ' + \"\"\"onload=\"{\n",
" let frame = this;\n",
" window.addEventListener('message', function(e) {\n",
" if (e.data.height) frame.style.height = (e.data.height+1) + 'px';\n",
Expand Down

0 comments on commit 80679ca

Please sign in to comment.