1
1
<!DOCTYPE html>
2
2
< html >
3
- < head >
4
- < meta charset ="utf-8 " />
5
- < title > RustPython Demo</ title >
6
- < style type ="text/css " media ="screen ">
7
- textarea {
8
- font-family : monospace;
9
- }
3
+ < head >
4
+ < meta charset ="utf-8 " />
5
+ < title > RustPython Demo</ title >
6
+ < style type ="text/css " media ="screen ">
7
+ textarea {
8
+ font-family : monospace;
9
+ resize : vertical;
10
+ }
10
11
11
- # code {
12
- height : 35vh ;
13
- width : 95vw ;
14
- }
12
+ # code {
13
+ height : 35vh ;
14
+ width : 95vw ;
15
+ }
15
16
16
- # console {
17
- height : 35vh ;
18
- width : 95vw ;
19
- }
17
+ # console {
18
+ height : 35vh ;
19
+ width : 95vw ;
20
+ }
20
21
21
- # run-btn {
22
- width : 6em ;
23
- height : 2em ;
24
- font-size : 24px ;
25
- }
22
+ # run-btn {
23
+ width : 6em ;
24
+ height : 2em ;
25
+ font-size : 24px ;
26
+ }
26
27
27
- # error {
28
- color : tomato;
29
- margin-top : 10px ;
30
- }
31
- </ style >
32
- </ head >
33
- < body >
34
- < h1 > RustPython Demo</ h1 >
35
- < p >
36
- RustPython is a Python interpreter writter in Rust. This demo is compiled
37
- from Rust to WebAssembly so it runs in the browser
38
- </ p >
39
- < p > Please input your python code below and click < kbd > Run</ kbd > :</ p >
40
- < p >
41
- Alternatively, open up your browser's devtools and play with
42
- < code > rp.eval_py('print("a")')</ code >
43
- </ p >
44
- < textarea id ="code ">
28
+ # error {
29
+ color : tomato;
30
+ margin-top : 10px ;
31
+ font-family : monospace;
32
+ }
33
+ </ style >
34
+ </ head >
35
+ < body >
36
+ < h1 > RustPython Demo</ h1 >
37
+ < p >
38
+ RustPython is a Python interpreter writter in Rust. This demo is
39
+ compiled from Rust to WebAssembly so it runs in the browser
40
+ </ p >
41
+ < p > Please input your python code below and click < kbd > Run</ kbd > :</ p >
42
+ < p >
43
+ Alternatively, open up your browser's devtools and play with
44
+ < code > rp.eval_py('print("a")')</ code >
45
+ </ p >
46
+ < textarea id ="code ">
45
47
n1 = 0
46
48
n2 = 1
47
49
count = 0
@@ -54,18 +56,34 @@ <h1>RustPython Demo</h1>
54
56
n1, n2 = n2, n1 + n2
55
57
count + = 1
56
58
57
- </ textarea >
58
- < button id ="run-btn "> Run ▷</ button >
59
- < div id ="error "> </ div >
60
- < script src ="./bootstrap.js "> </ script >
61
- < h3 > Standard Output</ h3 >
62
- < textarea id ="console "> Loading...</ textarea >
59
+ </ textarea >
60
+ < button id ="run-btn "> Run ▷</ button >
61
+ < div id ="error "> </ div >
62
+ < script src ="./bootstrap.js "> </ script >
63
+ < h3 > Standard Output</ h3 >
64
+ < textarea id ="console "> Loading...</ textarea >
63
65
64
- < a href ="https://github.com/RustPython/RustPython "
65
- > < img
66
- style ="position: absolute; top: 0; right: 0; border: 0; "
67
- src ="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png "
68
- alt ="Fork me on GitHub "
69
- /> </ a >
70
- </ body >
66
+ < p > Here's some info regarding the < code > rp.eval_py()</ code > function</ p >
67
+ < ul >
68
+ < li >
69
+ You can return variables from python and get them returned to
70
+ JS, with the only requirement being that they're serializable
71
+ with < code > json.dumps</ code > .
72
+ </ li >
73
+ < li >
74
+ You can pass an object as the second argument to the function,
75
+ and that will be available in python as the variable
76
+ < code > js_vars</ code > . Again, only values that can be serialized
77
+ with < code > JSON.stringify()</ code > will go through.
78
+ </ li >
79
+ </ ul >
80
+
81
+ <!-- "Fork me on GitHub" banner -->
82
+ < a href ="https://github.com/RustPython/RustPython "
83
+ > < img
84
+ style ="position: absolute; top: 0; right: 0; border: 0; "
85
+ src ="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png "
86
+ alt ="Fork me on GitHub "
87
+ /> </ a >
88
+ </ body >
71
89
</ html >
0 commit comments