Skip to content

Brown-University-Library/pyodide_example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Pyodide XML Validator Example

This directory contains small browser-based XML validator examples that run Python through Pyodide. The pages load Python in the browser, install the python-package xmlschema, and validate XML text against an XSD schema without requiring a backend service.

Files

  • xml_validator_01.html - self-contained example with the Python validation code embedded in the page.
  • xml_validator_02.html - example that loads validation logic from validator.py.
  • validator.py - Python helper used by xml_validator_02.html.

Installation

(Assumes uv is installed.)

git clone git@github.com:Brown-University-Library/pyodide_example.git
cd ./pyodide_example

Usage

Start a local static file server from this directory:

uv run --python 3.12 -m http.server 8000

Then open one of these pages in a browser:

Wait for the page to finish loading Pyodide and installing xmlschema. When the status says Ready., edit the XML or XSD text if needed and click Validate XML or Validate.

Notes

  • The first load may take a little while because Pyodide and Python packages are downloaded in the browser.
  • An internet connection is required unless the Pyodide runtime and Python packages are already cached by the browser.
  • Use the local server rather than opening the HTML files directly from disk. xml_validator_02.html fetches validator.py, which browsers commonly block from file:// pages.

About

Simple example of what pyodide (python in the browser) can do.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors