This project demonstrates how to run Python ASGI web applications entirely in the browser using Pyodide and a service worker, intercepting requests under a path and executing them via the ASGI protocol. Examples include FastAPI and the full Datasette app.
# Research: Running Python ASGI apps in the browser via Pyodide + a service worker
Source: [https://simonwillison.net/2026/May/30/pyodide-asgi-browser/](https://simonwillison.net/2026/May/30/pyodide-asgi-browser/)
[Research](https://simonwillison.net/elsewhere/research/)[Running Python ASGI apps in the browser via Pyodide \+ a service worker](https://github.com/simonw/research/tree/main/pyodide-asgi-browser#readme)— 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](https://lite.datasette.io/)is my version of Datasette that runs entirely in the browser using Pyodide in WebAssembly\.
When I first built it[four years ago](https://simonwillison.net/2022/May/4/datasette-lite/)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`<script\>`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](https://github.com/simonw/research/pull/112)\(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](https://simonw.github.io/research/pyodide-asgi-browser/)and here's[a demo that runs Datasette 1\.0a31](https://simonw.github.io/research/pyodide-asgi-browser/datasette.html)\.
I'm still getting my head around exactly how it works, but once I've done that I plan to upgrade Datasette Lite itself\.
Simon Willison introduces micropython-wasm, an alpha package that runs Python code in a sandbox using MicroPython compiled to WebAssembly, enabling safe plugin execution within Python applications like Datasette.
A test harness for experimenting with the Origin Private File System (OPFS) in browsers using Pyodide, built to explore persistent SQLite storage for Datasette Lite.
PyPI now supports publishing WebAssembly wheels for Pyodide, allowing package maintainers to distribute their own WASM packages directly. The article demonstrates this with the luau-wasm package.
Edge Python is a 170 KB WASM-based sandboxed Python subset that runs agent-generated code directly in the browser without a server, supporting classes, async/await, pattern matching, and more.
Datasette Apps is a new plugin that lets users host custom, sandboxed HTML+JavaScript applications within Datasette, enabling secure read-only and write SQL queries via iframes.