Python demo (x86_64)

Example of running Python (x86_64) on browser using container2wasm.

Source Container image

python:3.11-alpine

Terminal

[launch ENTRYPOINT] [launch shell (sh)] [disable networking]

It can take some time to load and start the container.

Example

Running the following in the container will get the contents of the demo page over HTTP.

import urllib.request
r = urllib.request.Request('https://ktock.github.io/container2wasm-demo/')
with urllib.request.urlopen(r) as response:
    body = response.read()
    print(body.decode('utf-8'))

Note

Container can perform HTTP(S) networking via the HTTP(S) proxy running on the browser. In the container, http_proxy, https_proxy, HTTP_PROXY and HTTPS_PROXY are pre-configured to the proxy's address (http://192.168.127.253:80). The proxy (+ networking stack) run on browser, relying on the browser's Fetch API. So out-of-browser proxy service is NOT used. HTTPS connection is terminated at the proxy and relies on Fetch API for re-encryption so the certificate for the proxy is configured as SSL_CERT_FILE=/.wasmenv/proxy.crt in the container.

The proxy is experimental and has limitations:

Please see also container2wasm repo for the details and other less-restricted networking methods (e.g. WebSocket + out-of-browser networking stack).


Tested on Google Chrome 116.0.5845.187. More info including docs and source code is available from container2wasm repo. This page is served from container2wasm-demo repo as GitHub Pages.

Back to top