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.

notebook/index.html

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1 @@
1-
<!DOCTYPE html>
2-
<html>
3-
4-
<head>
5-
<meta charset="utf-8" />
6-
<meta name="viewport" content="width=device-width, initial-scale=1">
7-
<title>RustPython Notebook</title>
8-
<link defer async href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans&family=Sen:wght@800&display=swap"
9-
rel="stylesheet">
10-
<link href="styles.css" rel="stylesheet"></head>
11-
12-
<body>
13-
14-
<div class="d-flex">
15-
<div class="header md-flex-grow text-center">RustPython 🐍 😱 🤘</div>
16-
<div>
17-
<a target="_blank" class="d-md-none mr-px-5 text-black" href="https://github.com/RustPython/RustPython/tree/master/wasm/notebook">how this works</a>
18-
<a target="_blank" class="text-black" href="https://github.com/RustPython/"> github</a>
19-
</div>
20-
</div>
21-
22-
<!-- navigation bar -->
23-
<div class="nav-bar mt-px-5">
24-
<div class="nav-bar-links d-flex d-flex-space-between d-sm-flex-direction-column">
25-
<div class="d-flex d-sm-flex-direction-column ">
26-
<a href="#" id="run-btn" class="bg-orange mr-px-5 text-white">run &#9658; </a>
27-
<ul class="list-inline sm-mt-5px" id="buffers-list"></ul>
28-
<ul class="list-inline sm-mt-5px">
29-
<li class="bg-light mr-px-5"> <a href="#" class="text-black" id="new-tab">new tab</a></li>
30-
<li class="bg-light mr-px-5"><a href="#popup" class="text-black" id="import-code">import code</a></li>
31-
</ul>
32-
</div>
33-
<div class="nav-bar-links d-flex sm-mt-5px">
34-
<ul class="list-inline ">
35-
<li class="d-md-none bg-light"><a href="#" id="split-view" class="mr-px-5 text-black">split view</a></li>
36-
<li class="d-md-none bg-light"><a href="#" id="default-view" class="mr-px-5 text-black">default view</a></li>
37-
<li class="d-md-none bg-light"><a href="#" id="reader-view" class="text-black">reader view</a></li>
38-
</ul>
39-
</div>
40-
</div>
41-
</div>
42-
43-
<!-- code editor and output display -->
44-
<!-- split view -->
45-
<div class="split-view full-height d-sm-flex-direction-column ">
46-
<div id="primary-editor"></div>
47-
<div id="secondary-editor" class="d-none">
48-
<select class="item-right" id="buffers-selection"></select>
49-
</div>
50-
51-
<div class="border-left" id="rp-notebook">loading python in your browser...</div>
52-
</div>
53-
54-
<!-- popup forms -->
55-
<div id="popup" data-type="python" class="overlay">
56-
<div class="popup">
57-
<div id="popup-header">Header Placeholder</div>
58-
<a class="popup-close" href="#">&times;</a>
59-
<div class="popup-content mt-px-5">
60-
<input type="url" name="popup-url" id="popup-url">
61-
<button id="popup-import" class="btn bg-black text-white">import</button>
62-
</div>
63-
</div>
64-
</div>
65-
66-
<!-- errors and keyboard shortcuts -->
67-
<div>
68-
<div class="header">Error(s):</div>
69-
<div id="error"></div>
70-
</div>
71-
<script type="text/javascript" src="index.js"></script></body>
72-
73-
</html>
1+
<!doctype html><html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"><title>RustPython Notebook</title><link defer="defer" async href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans&family=Sen:wght@800&display=swap" rel="stylesheet"><script defer="defer" src="index.js"></script><link href="styles.css" rel="stylesheet"></head><body><div class="d-flex"><div class="header md-flex-grow text-center">RustPython 🐍 😱 🤘</div><div><a target="_blank" class="d-md-none mr-px-5 text-black" href="https://github.com/RustPython/RustPython/tree/main/wasm/notebook">how this works</a> <a target="_blank" class="text-black" href="https://github.com/RustPython/">github</a></div></div><div class="nav-bar mt-px-5"><div class="nav-bar-links d-flex d-flex-space-between d-sm-flex-direction-column"><div class="d-flex d-sm-flex-direction-column"><a href="#" id="run-btn" class="bg-orange mr-px-5 text-white">run &#9658;</a><ul class="list-inline sm-mt-5px" id="buffers-list"></ul><ul class="list-inline sm-mt-5px"><li class="bg-light mr-px-5"><a href="#" class="text-black" id="new-tab">new tab</a></li><li class="bg-light mr-px-5"><a href="#popup" class="text-black" id="import-code">import code</a></li></ul></div><div class="nav-bar-links d-flex sm-mt-5px"><ul class="list-inline"><li class="d-md-none bg-light"><a href="#" id="split-view" class="mr-px-5 text-black">split view</a></li><li class="d-md-none bg-light"><a href="#" id="default-view" class="mr-px-5 text-black">default view</a></li><li class="d-md-none bg-light"><a href="#" id="reader-view" class="text-black">reader view</a></li></ul></div></div></div><div class="split-view full-height d-sm-flex-direction-column"><div id="primary-editor"></div><div id="secondary-editor" class="d-none"><select class="item-right" id="buffers-selection"></select></div><div class="border-left" id="rp-notebook">loading python in your browser...</div></div><div id="popup" data-type="python" class="overlay"><div class="popup"><div id="popup-header">Header Placeholder</div><a class="popup-close" href="#">&times;</a><div class="popup-content mt-px-5"><input type="url" name="popup-url" id="popup-url"> <button id="popup-import" class="btn bg-black text-white">import</button></div></div></div><div><div class="header">Error(s):</div><div id="error"></div></div></body></html>

notebook/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/styles.css

Lines changed: 14 additions & 18 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)