Running Python ASGI apps in the browser via Pyodide + a service worker
Simon Willison's recent exploration details a method for executing Python ASGI applications directly within a web browser environment, published on May 30, 2026. This technique combines Pyodide, a WebAssembly port of CPython, with a service worker to intercept network requests and route them to a Python ASGI application running client-side. The service worker acts as a proxy, allowing standard ASGI frameworks such as FastAPI or Starlette to function without a traditional backend server. By compiling Python code to WebAssembly via Pyodide, the browser can interpret and run complex Python logic, effectively turning the browser into a Python execution environment for web applications. This setup enables developers to build web applications where significant portions of the server-side logic, including API endpoints, can be offloaded to the client, reducing the need for constant server communication. The article highlights the potential for creating highly interactive, performant, and potentially offline-capable web experiences. This client-side execution improves responsiveness by eliminating network round-trips for certain operations and can significantly lower infrastructure costs for applications that can leverage client-side computation. Willison's work demonstrates a novel way to bridge Python's robust ecosystem with modern web browser capabilities, pushing the boundaries of what's possible for client-side web development. This approach could be particularly beneficial for data visualization tools, interactive dashboards, or even full-fledged web applications that require minimal backend interaction after initial load.
Developers can now build full-stack Python web applications that run entirely in the browser, reducing server load and enabling offline capabilities.