Image

Daniel Roy Greenfeld: Using pyinstrument to profile FastHTML apps

FastHTML is built on Starlette, so we use Starlette's middleware tooling and then pass in the result. Just make sure you install pyinstrument.

WARNING: NOT FOR PRODUCTION ENVIRONMENTSIncluding a profiler like this in a production environment is dangerous. As it exposes infrastructure it is highly risky to include in any location where end users can access it.

To invoke, make any request to your application with the GET parameterprofile=1and it will print the HTML result from pyinstrument.

https://daniel.feldroy.com/posts/2025-03-using-pyinstrument-to-profile-fasthtml-apps