-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode_editor.html
33 lines (31 loc) · 1.23 KB
/
code_editor.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SnakeCodeEditor</title>
<link rel="icon" href="logo.jpg">
<script src="https://cdn.jsdelivr.net/npm/brython@3.12.3/brython.min.js" integrity="sha256-5S+uyI6JXTLNxOAgBefqpfBerBAl/sgb8DYOmGvBrE0=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="style.css">
</head>
<body onload="brython()">
<div id="editor">
<textarea id="python-code" placeholder="Write your Python code here..."></textarea>
<span><button id="run-button">
<span class="run-icon">►</span> Run Code
</button></span>
<button class="button" onclick="saveText()">Save</button>
<button class="button" onclick="importText()">Import</button>
</div>
<script type="text/python">
from browser import document
def run_python(event):
try:
exec(document["python-code"].value)
except Exception as e:
print("Error: " + str(e))
document["run-button"].bind("click", run_python)
</script>
<script src="main.js"></script>
</body>
</html>