Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import execjs
|
2 |
+
|
3 |
+
# Define some JavaScript code
|
4 |
+
js_code = """
|
5 |
+
function addNumbers(a, b) {
|
6 |
+
return a + b;
|
7 |
+
}
|
8 |
+
|
9 |
+
var result = addNumbers(2, 3);
|
10 |
+
"""
|
11 |
+
|
12 |
+
# Use execjs to execute the JavaScript code
|
13 |
+
ctx = execjs.compile(js_code)
|
14 |
+
|
15 |
+
# Get the result of the JavaScript code
|
16 |
+
result = ctx.eval('result')
|
17 |
+
|
18 |
+
# Print the result
|
19 |
+
print(result)
|