API

serve_dev()

The serve_dev() function is a wrapper around the FastHTML serve() function, adding utilities to enhance the development experience.


source

serve_dev

 serve_dev (app='app', host='0.0.0.0', port=None, reload=True,
            reload_includes=None, reload_excludes=None, sqlite_port=8035,
            db=False, db_path='data/app.db', jupyter=False,
            jupyter_port=8036, tw=False, tw_src='./app.css',
            tw_dist='./public/app.css')

Utility function to start FastHTML, TailwindCSS, Jupyter Lab, and SQLite in development mode

Type Default Details
app str app FastHTML (Starlette) class instance
host str 0.0.0.0 Uvicorn host
port NoneType None Uvicorn port
reload bool True Uvicorn reload status
reload_includes NoneType None Files to watch to reload Uvicorn
reload_excludes NoneType None Files to exclude from watching to reload Uvicorn
sqlite_port int 8035 sqlite-web port
db bool False Enable SQLIte browser
db_path str data/app.db SQLite database path
jupyter bool False Enable Jupyter Lab
jupyter_port int 8036 Jupyter Lab port
tw bool False Enable TailwindCSS
tw_src str ./app.css TailwindCSS source file
tw_dist str ./public/app.css TailwindCSS output file

cache_buster()

It can be annoying sometimes when FastHTML live reload is enabled and you’re quickly iterating on CSS changes and the styles sometimes get cached between page loads. When this happens you have to manually clear the browser cache and reload the page.

The cache_buster() function adds a unique timestamp string to the CSS file added to the site header which is different every page load, so this should eliminate browser caching of CSS leading to a smoother development workflow.


source

cache_buster

 cache_buster ()

Helps to avoid browser caching of dynamically generated CSS during development