Running the full server-side Datasette Python app in the browser with service workers and Pyodide
1 tiếng nói · chưa gắn nhãn trưởng lab · 2 nền tảng · chưa có số tương tác · Nguồn crawl
Chi tiết nguồn
<p><a href="https://lite.datasette.io/">Datasette Lite</a> is my port of the <a href="https://datasette.io/">Datasette</a> Python application to run directly in the browser using WebAssembly and <a href="https://pyodide.org/">Pyodide</a>. I've released a complete rewrite of Datasette Lite using service workers, and it's now almost indistinguishable from the real server-side application.</p> <p>You can now do all of the following, using a carefully crafted URL to <strong>lite.datasette.io</strong>:</p> <ul> <li>Load client-side Datasette to browse any SQLite database, JSON file, CSV file or SQL script</li> <li>Select a released version of Datasette to load from PyPI</li> <li>Load a specific commit, tag, or branch name from the Datasette GitHub repository</li> <li>Pick from over 100 versions of SQLite to use with Datasette</li> <li>Install additional Datasette plugins from PyPI or URLs to wheel files, including JavaScript visualization tools</li> </ul> <p>The ability to load specific Datasette references, plugins, and SQLite versions makes this a fantastic tool for linking to demos of work-in-progress features or bug reproductions, without needing to spin up a full web server to serve that demo.</p> <p>As an example, consider the following URL:</p> <p><a href="https://lite.datasette.io/?install=datasette-maplibre&url=https://gist.githubusercontent.com/simonw/39fa5d399465766039549912e2b3d291/raw/f6dfba99a75cbb8b5d9386223220eb52272767ee/demo.db&metadata=https://gist.githubusercontent.com/simonw/39fa5d399465766039549912e2b3d291/raw/f6dfba99a75cbb8b5d9386223220eb52272767ee/metadata.yml#/demo/capitals_and_countries%23map=0/4.2/180&color=continent">https://lite.datasette.io/?install=datasette-maplibre&url=https://gist.githubusercontent.com/simonw/39fa5d399465766039549912e2b3d291/raw/f6dfba99a75cbb8b5d9386223220eb52272767ee/demo.db&metadata=https://gist.githubusercontent.com/simonw/39fa5d399465766039549912e2b3d291/raw/f6dfba99a75cbb8b5d9386223220eb52272767ee/metadata.yml#/demo/capitals_and_countries%23map=0/4.2/180&color=continent</a></p> <p>Follow that link and, after a short loading screen, you'll find yourself on a page that looks like this:</p> <p><img src="https://static.simonwillison.net/static/cors-allow/2026/datasette-maplibre.webp" alt="Screenshot of a web map interface. Toolbar: "View" set to "Clusters", "Colour by" set to "continent", plus "Filter to this area" and "Download GeoJSON" buttons. A world map shows countries outlined and shaded by continent, with coloured dots and numbered cluster circles. A popup for a point in South America reads: capital Caracas, country Venezuela, continent South America, capital_population 2985000, latitude 10.502944, longitude -66.918983. Legend: Africa (52), Asia (45), Europe (39), North America (16), South America (13), Oceania (6). Text: "All 171 rows are on the map". Below, a table with columns country, continent, capital_population, latitude, longitude, boundary. First row: Afghanistan, Asia, 3277000, 34.518636, 69.181314, with a small map in the boundary column showing Afghanistan outlined and shaded in blue." style="max-width: 100%;" /></p> <p>That's Datasette running the new <a href="https://github.com/datasette/datasette-maplibre">datasette-maplibre</a> plugin, loading up a database of GeoJSON shapes of countries and displaying both a combined map and individual boundary maps in a table.</p> <p>Let's break down that URL to see what it's doing:</p> <pre><code>https://lite.datasette.io/ ?install=datasette-maplibre &url=https://.../demo.db &metadata=https://.../metadata.yml #/demo/capitals_and_countries%23map=0/4.2/180&color=continent </code></pre> <p>The <code>?install=datasette-maplibre</code> installs that additional plugin from PyPI. You can pass <code>&install=...</code> as many times as you like to load more plugins.</p> <p><code>&url=https://.../demo.db</code> loads that SQLite database from the provided URL. These URLs need to have <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS">open CORS headers</a> - I host files like this in <a href="https://gist.github.com/">Gists</a>, because they provide an easy way to get open CORS headers on a web-hosted file.</p> <p><code>&metadata=https://.../metadata.yml</code> loads <a href="https://gist.githubusercontent.com/simonw/39fa5d399465766039549912e2b3d291/raw/f6dfba99a75cbb8b5d9386223220eb52272767ee/metadata.yml">this metadata.yml file</a>. The metadata file adds HTML descriptions to various tables, and to the Datasette homepage. Visit <a href="https://lite.datasette.io/?install=datasette-maplibre&url=https://gist.githubusercontent.com/simonw/39fa5d399465766039549912e2b3d291/raw/f6dfba99a75cbb8b5d9386223220eb52272767ee/demo.db&metadata=https://gist.githubusercontent.com/simonw/39fa5d399465766039549912e2b3d291/raw/f6dfba99a75cbb8b5d9386223220eb52272767ee/metadata.yml#/">that homepage here</a> for a guided tour of the other features of that plugin, all defined in the metadata file.</p> <p><code>#/demo/capitals_and_countries%23map=0/4.2/180&color=continent</code> is a fragment hash that turns into a location within Datasette - here it's loading the <code>/demo/capitals_and_countries</code> SQL view, then appending <em>another</em> fragment hash to it (<code>%23</code> is a URL-encoded <code>#</code>) which tells the map plugin to zoom to a certain location and to set the color of the shapes on the map based on the <code>continent</code> column in the data.</p> <p>That URL is doing a lot of work! I wrote more about this trick for building URL-addressable software in <a href="https://simonwillison.net/2025/Feb/13/url-addressable-python/">URL-addressable Pyodide Python environments</a> last year.</p> <p>The full set of supported URL arguments is <a href="https://github.com/simonw/datasette-lite#load-a-different-datasette-version">described in the Dataset
- Running the full server-side Datasette Python app in the browser with service workers and Pyodide Simon Willison · 17 thg 11, 2026
- I shipped a new version of Datasette Lite recently - my build of the Datasette Python web app that runs entirely in the browser with WebAssembly and Pyodide - here's what's new and how it all works X · 18 thg 11, 2026