Configuration
Given this HTML/JSON fragment:
<py-config>
{
"interpreter": "micropython",
"files": {
"arrr.py": "/arrr.py"
}
}
</py-config>
We're able to configure various things:
- The Python interpreter to use underneath the PyScript platform (currently MicroPython and Pyodide are supported).
- Files to be copied onto the interpreter's virtual filesystem. The
filesobject contains key (filename) and value (the URL containing the content of the file) pairs defining what should be copied over.
If you "view source" for this page, you'll see we ensure the Arrr Python module is copied over to the filesystem. Just import it, as usual, to make use of it in your code:
<py-script>import arrr
text = "Hello there, from MicroPython running in the browser!"
pirate_text = arrr.translate(text)
print(pirate_text)
</py-script>
Once again, "view-source" and see for yourself?