Skip to content

Commit

Permalink
Merge pull request #506 from siralmat/main
Browse files Browse the repository at this point in the history
Update live reload documentation
  • Loading branch information
jph00 authored Oct 10, 2024
2 parents d856beb + cb45804 commit 11014ab
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion fasthtml/live_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class FastHTMLWithLiveReload(FastHTML):
>>> app = FastHTMLWithLiveReload()
Run:
run_uv()
serve()
"""
LIVE_RELOAD_ROUTE = WebSocketRoute("/live-reload", endpoint=live_reload_websocket)

Expand Down
3 changes: 2 additions & 1 deletion nbs/ref/live_reload.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"**⚠️ Gotchas**\n",
"- A reload is only triggered when you save your changes.\n",
"- `FastHTMLWithLiveReload` should only be used during development.\n",
"- If your app spans multiple directories you might need to use the `--reload-dir` flag to watch all files in each directory. See the uvicorn [docs](https://www.uvicorn.org/settings/#development) for more info."
"- If your app spans multiple directories you might need to use the `--reload-dir` flag to watch all files in each directory. See the uvicorn [docs](https://www.uvicorn.org/settings/#development) for more info.\n",
"- The live reload script is only injected into the page when rendering [ft components](https://docs.fastht.ml/explains/explaining_xt_components.html)."
]
},
{
Expand Down
14 changes: 7 additions & 7 deletions nbs/tutorials/by_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,7 @@
"INFO: Application startup complete.\n",
"```\n",
"\n",
"If you navigate to [http://127.0.0.1:8000](http://127.0.0.1:8000) in a browser, you'll see your \"Hello, World\". If you edit the `app.py` file and save it, the server will reload and you'll see the updated message when you refresh the page in your browser. \n",
"\n",
":::{.callout-tip}\n",
"# Live Reloading\n",
"You can also enable [live reloading](../ref/live_reload.ipynb) so you don't have to manually refresh your browser while editing it.\n",
":::"
"If you navigate to [http://127.0.0.1:8000](http://127.0.0.1:8000) in a browser, you'll see your \"Hello, World\". If you edit the `app.py` file and save it, the server will reload and you'll see the updated message when you refresh the page in your browser."
]
},
{
Expand Down Expand Up @@ -197,7 +192,12 @@
"source": [
"This will render the HTML in the browser.\n",
"\n",
"For debugging, you can right-click on the rendered HTML in the browser and select \"Inspect\" to see the underlying HTML that was generated. There you'll also find the 'network' tab, which shows you the requests that were made to render the page. Refresh and look for the request to `127.0.0.1` - and you'll see it's just a `GET` request to `/`, and the response body is the HTML you just returned."
"For debugging, you can right-click on the rendered HTML in the browser and select \"Inspect\" to see the underlying HTML that was generated. There you'll also find the 'network' tab, which shows you the requests that were made to render the page. Refresh and look for the request to `127.0.0.1` - and you'll see it's just a `GET` request to `/`, and the response body is the HTML you just returned.\n",
"\n",
":::{.callout-tip}\n",
"# Live Reloading\n",
"You can also enable [live reloading](../ref/live_reload.ipynb) so you don't have to manually refresh your browser to view updates.\n",
":::"
]
},
{
Expand Down

0 comments on commit 11014ab

Please sign in to comment.