CodePlayground/python.html

57 lines
1.8 KiB
HTML

<!DOCTYPE html>
<html lang="fr">
<head>
<title>Python Playground</title>
<meta charset="utf-8" />
<script src="lib/codeflask.min.js"></script>
<script src="lib/prism-python.min.js"></script>
<script src="lib/brython.min.js"></script>
<script src="lib/brython_stdlib.min.js"></script>
<link rel="stylesheet" href="assets/css/main.css" type="text/css" />
</head>
<body>
<header>
<h1>Python Playground</h1>
</header>
<div id="container">
<div id="codeContainer"><div id="code"></div></div><!--
--><div id="console">
</div>
<input type="button" onclick="example()" value="Exemple" id="exBtn" /><!--
--><input type="button" onclick="run()" value="Exécuter !" id="runBtn" /><!--
--><input type="button" onclick="clearCode()" value="Effacer" id="clearBtn" />
</div>
<footer>
Romain de Laage - CC0
</footer>
<script type="text/python" id="pyinit">
import sys
from browser import document
# Define new class to bind html element with std files
class Stdfile() :
def __init__(self, elmtId, error = False):
self.elmt = document[elmtId]
self.error = error
def write(self, text):
if self.error == True:
self.elmt.html = self.elmt.html + '<div class="error">' + text.replace('\n', '<br />') + '</div>'
else:
self.elmt.html = self.elmt.html + '<div class="message">' + text.replace('\n', '<br />') + '</div>'
# Bind stderr and stdout with console element of page
sys.stderr = Stdfile('console', True)
sys.stdout = Stdfile('console')
</script>
<script type="text/python" id="pyclear">
from browser import document
# Clear console
document['console'].html = ''
</script>
<script type="text/python" id="pycode"></script>
<script src="assets/js/editor.js"></script>
<script src="assets/js/pypg.js"></script>
</body>
</html>