For privacy reasons or for those needing to use browser-based sketches without "full" internet access (like for offline Progressive Web Apps or behind firewalls), developers can also
download a copy of the required files for full self-hosting. By default, these assume that they are located in a directory called "third_party" at the root of the server and can be included like so:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!-- You may need to change these paths to pyscript files. -->
<link rel="stylesheet" href="/third_party/pyscript/core.css">
<script type="module" src="/third_party/pyscript/core.js"></script>
</head>
<body>
<py-config>
interpreter = "http://localhost:8000/third_party/pyodide/pyodide.mjs"
packages = ["http://localhost:8000/third_party/sketchingpy-0.3.2-py3-none-any.whl"]
</py-config>
<!-- You may need to change this ID to match your code. -->
<div id="sketch-load-message">Loading...</div>
<canvas id="sketch-canvas"></canvas>
<!-- You can link the script as shown below or use py-script to inline -->
<script type="py" src="main.py"></script>
</body>
</html>
You may need to change localhost to your domain name. Also, if hosting these files under a different path, change "third_party" above. Note that zip file use sources from other open source projects including those from the PyScript project subject to their permissive
license. For more information, see the
PyScript user guide. Also, please see the underlying sources as, under certain configurations like use of pypi packages, this "self-hosted" version may still caues external network traffic. Finally, for privacy-sensitive use cases, consider using a browser's web inspector to look for traffic to confirm other servers beyond those intended one are not contacted.