Hello, love the project. I’m trying to write my own simple REPL. I’d like to use the PyScript functionality to compile code, without the frontend boilerplate of py-repl. How can I take user input and run it manually? Here’s the gist of the code I have so far:
<div id="py-container">
</div>
<div class="row col-12">
<textarea id="python-editor"></textarea>
<button id="run-button" class="btn btn-primary">Run</button>
</div>
<div id='output-container' class="row">
<div id="out"></div>
</div>
<script>
$('#run-button').click(function() {
let code =$('#python-editor').val();
let code_final = '<py-script id="input" output="out" output-mode="append"> ' + code + ' </py-script>'
$('#py-container').append(code_final);
});
</script>
I’m using codemirror on my end, so I simplified the code a bit, but I did confirm that code_final returns
<py-script id="input" output="out" output-mode="append"> print('x') </py-script>
. If I put this line directly in my code, it compiles on page load and “x” appears in the output div.