- returns promise that is resolved when the code finishes
- if the Python code returns something, it gets set as the promise's value
- allows you to pass dictionary of varibles that can be used by the python script
- ⚠ All of the Brython code is owned by the authors of brython-dev/brython and i have no intention to misuse the code ⚠
- ⚠ This package is 1MB - 4MB (depending on File chooser) in size, not recommended for production ⚠
- This package is used standalone, all dependencies are included
- Not tested concurrently with Brython
- Use at your own risk, bugs may be present!
1. Find your file in File chooser below and click on it's name
- Just add
<script src="https://cdn.jsdelivr.net/gh/MP3Martin/jsRUNpy.js@1/jsRUNpy.min.js"></script>
- in your
<head>
tags
Click on the file's name and read what the page says
-
jsRUNpy.js
- uncompressed file, nearly 4MB, not recommended -
jsRUNpy.min.js
- compressed file, nearly 4MB, ✅recommended✅, (not located in this repo, it is automatically generated using jsDelivr) -
jsRUNpy.min.extreme.js
- extremely compressed file using streamich/crunchme, nearly 1MB, not recommended, ¼ size of the recommended file, but can lag your browser for a few seconds (depending on the hardware)
Emoji | Meaning |
---|---|
✅ | Mandatory argument |
🟨 | Optional argument |
-
jsRUNpy.run(
✅code: string,
🟨variables: object)
jsRUNpy.run("print(test)", {test: "Hello World!"})
is same as
jsRUNpy.run("print('Hello World!')")
jsRUNpy.run("return 33 + 77").then(out => {console.log("Python code outputted: " + out)})
is same as
(async () => { out = await jsRUNpy.run("return 33 + 77") console.log("Python code outputted: " + out) })()
jsRUNpy.run(` print(1) print(2) `)
is same as
jsRUNpy.run("print(1)\nprint(2)")
and is same as
for (i = 1; i <= 2; i++) { jsRUNpy.run("print(i)", {i: i}) }
test = "Hello!" jsRUNpy.run(` from browser import window window["test"] = "Hi!" `).then(()=>{console.log(test)})
for (i = 0; i <= 10; i++) { jsRUNpy.run("print(i)", {i: i}) }