Skip to content

Commit

Permalink
added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
modularizer committed Oct 15, 2022
1 parent b71a255 commit 3bd6e1e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
15 changes: 4 additions & 11 deletions min.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>PyPrez</title>
</head>
<body>
<script src="https://modularizer.github.io/pyprez/pyprez.js" mode="editor">
import numpy as np
print("testing")
np.random.rand(5)
<!-- shortest pyprez example possible -->
<script src="https://modularizer.github.io/pyprez/pyprez.js">
import random
random.random()
</script>
<pyprez-editor language="js">
pyprez.loadAndRunAsync(`
from js import alert
alert("pyodide object has loaded and is available at window.pyodide")
`)
</pyprez-editor>
</body>
</html>
4 changes: 2 additions & 2 deletions pyprez.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pyprez</title>
<title>PyPrez</title>

<script src="./pyprez.js"></script>
</head>
<body>
<!-- pre-load libraries if you wish -->
<!-- pre-load libraries if you wish, not really necessary -->
<pyprez-import>
-numpy
</pyprez-import>
Expand Down
12 changes: 12 additions & 0 deletions sample_front_end_python.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
"""
the <pyprez-editor> tag can take an attribute src='./path_to_some_python_file_served_online.py' and it will display the
content for you to edit and run.
the <pyprez-script> tag can similarly take a src attribute, but it will execute the python script as soon as it loads
instead of putting it into a code demo text box.
this is a sample script that can be imported to test the <pyprez-editor> and <pyprez-script> tags.
"""

import numpy as np

for i in range(5):
print(np.random.rand(5)) # this should print to the developer console with console.log
# unless the stdout has already been rerouted by using javascript, e.g. pyprez.stdout=alert
5 changes: 4 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
"""this script can be used to launch a basic tornado static file handler to serve files for your project"""
"""this script can be used to launch a basic tornado static file handler to serve files for your project
if you want to locally host the pyprez.js file instead of retrieving it from
https://modularizer.github.io/pyprez/pyprez.js
"""
import asyncio
import sys

Expand Down

0 comments on commit 3bd6e1e

Please sign in to comment.