Research: Running Python ASGI apps in the browser via Pyodide + a service worker
Simon Willison’s Weblog
Subscribe
Sponsored by: The AI App and Agent Factory — Microsoft Foundry is the enterprise Al platform where intelligence and trust ship with every agent. Try Foundry
30th May 2026
Research
Running Python ASGI apps in the browser via Pyodide + a service worker<br>— By running Python ASGI web applications entirely in the browser using Pyodide and a dedicated service worker, this project intercepts all same-origin requests under `/app/` and executes them against the Python app via the ASGI protocol—removing the need for a backend server except for static files. The mechanism is demonstrated with both a FastAPI demo and the full Datasette app, confirming its generality across ASGI apps.
Datasette Lite is my version of Datasette that runs entirely in the browser using Pyodide in WebAssembly.
When I first built it four years ago I used Web Workers and code that intercepts navigation operations and fetches the generated HTML by running the Python app.
This worked, but had the disadvantage that any JavaScript in tags would not be executed - breaking some Datasette functionality and a whole lot of Datasette plugins.
This morning I set Claude Opus 4.8 the task (in Claude Code for web) of figuring out how to run Python ASGI apps in Pyodide using Service Workers instead, and it seems to work! Here's a basic ASGI FastCGI demo and here's a demo that runs Datasette 1.0a31.
I'm still getting my head around exactly how it works, but once I've done that I plan to upgrade Datasette Lite itself.
Posted 30th May 2026 at 9:02 pm
Recent articles
Claude Opus 4.8: "a modest but tangible improvement" - 28th May 2026
I think Anthropic and OpenAI have found product-market fit - 27th May 2026
Notes on Pope Leo XIV's encyclical on AI - 25th May 2026
This is a beat by Simon Willison, posted on 30th May 2026.
javascript<br>756
python<br>1,252
datasette<br>1,502
asgi<br>22
service-workers
pyodide<br>26
datasette-lite<br>21
claude-code<br>115
Monthly briefing
Sponsor me for $10/month and get a curated email digest of the month's most important LLM developments.
Pay me to send you less!
Sponsor & subscribe
Disclosures
Colophon
©
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026