-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
45 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Pyodide Project | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Pyodide Examples | ||
|
||
Use the `./server.py` to serve the files. If you request "some_directory.zip" it | ||
the server will zip the directory on the fly and serve it. This is useful for | ||
developing Python packages for use with Pyodide. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="https://cdn.jsdelivr.net/pyodide/dev/full/pyodide.js"></script> | ||
<script src="https://cdn.jsdelivr.net/pyodide/dev/full/pyodide.js"></script> | ||
</head> | ||
<body> | ||
Pyodide test page <br> | ||
Pyodide test page <br /> | ||
Open your browser console to see Pyodide output | ||
<script type="text/javascript"> | ||
async function main(){ | ||
const pkgResponse = fetch("hello_world.zip").then(x => x.arrayBuffer()); | ||
async function main() { | ||
const pkgResponse = fetch("hello_world.zip").then((x) => | ||
x.arrayBuffer() | ||
); | ||
window.pyodide = await loadPyodide({ | ||
indexURL : "https://cdn.jsdelivr.net/pyodide/dev/full/" | ||
indexURL: "https://cdn.jsdelivr.net/pyodide/dev/full/", | ||
}); | ||
const pkgdata = await pkgResponse; | ||
console.log("Unpacking package"); | ||
pyodide.unpackArchive(pkgdata, "zip"); | ||
console.log("Importing hello world"); | ||
window.pkg = pyodide.pyimport("hello_world"); | ||
console.log(`pkg.say_hello("John!"):`); | ||
pkg.say_hello("John!"); | ||
console.log( | ||
`pkg.repeat_string("John!", 4):`, | ||
pkg.repeat_string("John!", 4) | ||
); | ||
} | ||
main(); | ||
</script> | ||
</body> | ||
</html> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters