| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
Import Python utilities directly in JS
// main thread
const { ffi: { func_a, func_b } } = await import('./test.js');
// test.js
import bridge from 'https://esm.run/@pyscript/bridge';
export const ffi = bridge(import.meta.url, { type: 'mpy', worker: false });
// test.py
def func_a(value):
print(f"hello {value}")
def func_b():
import sys
return sys.versionRun npx mini-coi . within this folder to then reach out http://localhost:8080/test/ that will show:
PyScript Bridge ------------------ no config
The test.js files uses the following defaults:
To test any variant use query string parameters so that ?type=py will use py instead, worker will use a worker and config will use a basic config that brings in another file from the same folder which exposes the version.
To recap: http://localhost:8080/test/?type=py&worker&config will show this instead:
PyScript Bridge ------------------ 3.12.7 (main, May 15 2025, 18:47:24) ...
Please note when a config is used, the worker attribute is always true.
| Back | FazBrowse Home | New Git URL |