Skip to content

Commit 33221db

Browse files
committed
1 parent 9e3e511 commit 33221db

File tree

73 files changed

+73
-564
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+73
-564
lines changed

.nojekyll

Whitespace-only changes.

1.index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

531.index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

index.html

Lines changed: 1 addition & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1 @@
1-
<!DOCTYPE html>
2-
<html>
3-
<head>
4-
<meta charset="utf-8" />
5-
<title>RustPython Demo</title>
6-
<link href="styles.css" rel="stylesheet"></head>
7-
<body>
8-
<h1>RustPython Demo</h1>
9-
<p>
10-
RustPython is a Python interpreter written in Rust. This demo is
11-
compiled from Rust to WebAssembly so it runs in the browser.<br>
12-
Input your Python code below and click <kbd>Run</kbd>
13-
(or <kbd>Ctrl+Enter</kbd>), or you can open up your
14-
browser's devtools and play with <code>rp.pyEval('1 + 1')</code>
15-
</p>
16-
<div id="code-wrapper">
17-
<textarea id="code">n1 = 0
18-
n2 = 1
19-
count = 0
20-
until = 10
21-
22-
print(f"These are the first {until} numbers in the Fibonacci sequence:")
23-
24-
while count < until:
25-
print(n1)
26-
n1, n2 = n2, n1 + n2
27-
count += 1
28-
</textarea>
29-
<select id="snippets">
30-
31-
<option
32-
33-
>asyncbrowser</option>
34-
35-
<option
36-
37-
>fetch</option>
38-
39-
<option
40-
selected
41-
>fibonacci</option>
42-
43-
<option
44-
45-
>fizzbuzz</option>
46-
47-
<option
48-
49-
>mandelbrot</option>
50-
51-
</select>
52-
</div>
53-
<button id="run-btn">Run &#9655;</button>
54-
<div id="error"></div>
55-
<h3>Standard Output</h3>
56-
<textarea id="console" readonly>Loading...</textarea>
57-
58-
<h3>Interactive shell</h3>
59-
<div id="terminal"></div>
60-
61-
<p>
62-
Here's some info regarding the <code>rp.pyEval()</code>,
63-
<code>rp.pyExec()</code>, and <code>rp.pyExecSingle()</code>
64-
functions
65-
</p>
66-
<ul>
67-
<li>
68-
You can return variables from python and get them returned to
69-
JS, with the only requirement being that they're serializable
70-
with <code>json.dumps</code>.
71-
</li>
72-
<li>
73-
You can pass an options object as the second argument to the
74-
function:
75-
<ul>
76-
<li>
77-
<code>stdout</code>: either a string with a css selector
78-
to a textarea element or a function that receives a
79-
string when the <code>print</code> function is called in
80-
python. The default value is <code>console.log</code>.
81-
</li>
82-
<li>
83-
<code>vars</code>: an object that will be available in
84-
python as the variable <code>js_vars</code>. Only
85-
functions and values that can be serialized with
86-
<code>JSON.stringify()</code> will go through.
87-
</li>
88-
</ul>
89-
</li>
90-
<li>
91-
JS functions that get passed to python will receive positional
92-
args as positional args and kwargs as the
93-
<code>this</code> argument
94-
</li>
95-
</ul>
96-
97-
<p>
98-
Limited Interaction with browser is possible from Python by using
99-
the <code>browser</code> module. Browser APIs such as
100-
<code>alert()</code>, <code>confirm()</code>, <code>prompt()</code>
101-
and <code>fetch()</code> are included in the module.
102-
</p>
103-
104-
<a href="https://github.com/RustPython/RustPython">
105-
<img
106-
style="position: absolute; top: 0; right: 0; border: 0;"
107-
src="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png"
108-
alt="Fork me on GitHub"
109-
/>
110-
</a>
111-
<script type="text/javascript" src="index.js"></script></body>
112-
</html>
1+
<!doctype html><html><head><meta charset="utf-8"/><title>RustPython Demo</title><script defer="defer" src="index.js"></script><link href="styles.css" rel="stylesheet"></head><body><h1>RustPython Demo</h1><p>RustPython is a Python interpreter written in Rust. This demo is compiled from Rust to WebAssembly so it runs in the browser.<br>Input your Python code below and click <kbd>Run</kbd> (or <kbd>Ctrl+Enter</kbd>), or you can open up your browser's devtools and play with <code>rp.pyEval('1 + 1')</code></p><div id="code-wrapper"><select id="snippets"><option>asyncbrowser</option><option>fetch</option><option selected="selected">fibonacci</option><option>fizzbuzz</option><option>import_pypi</option><option>mandelbrot</option></select></div><button id="run-btn">Run &#9655;</button><div id="error"></div><h3>Standard Output</h3><textarea id="console" readonly="readonly">Loading...</textarea><h3>Interactive shell</h3><div id="terminal"></div><p>Here's some info regarding the <code>rp.pyEval()</code>, <code>rp.pyExec()</code>, and <code>rp.pyExecSingle()</code> functions</p><ul><li>You can return variables from python and get them returned to JS, with the only requirement being that they're serializable with <code>json.dumps</code>.</li><li>You can pass an options object as the second argument to the function:<ul><li><code>stdout</code>: either a string with a css selector to a textarea element or a function that receives a string when the <code>print</code> function is called in python. The default value is <code>console.log</code>.</li><li><code>vars</code>: an object that will be available in python as the variable <code>js_vars</code>. Only functions and values that can be serialized with <code>JSON.stringify()</code> will go through.</li></ul></li><li>JS functions that get passed to python will receive positional args as positional args and kwargs as the <code>this</code> argument</li></ul><p>Limited Interaction with browser is possible from Python by using the <code>browser</code> module. Browser APIs such as <code>alert()</code>, <code>confirm()</code>, <code>prompt()</code> and <code>fetch()</code> are included in the module.</p><a href="https://github.com/RustPython/RustPython"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://github.blog/wp-content/uploads/2008/12/forkme_right_green_007200.png" alt="Fork me on GitHub"/></a></body></html>

index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

notebook/1.index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

notebook/531.index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)