I want to host a python script on a website with pyscript, which has both console input and console output. If I want to give it a console input via the input("test") function, then just comes
and i can't see the output with print("output") either.
I then found an example script, but it only works 1.
<!DOCTYPE html>
<html>
<head>
<!--<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />-->
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
</head>
<body>
<div>textfield_1</div>
<input type="text" id="test-input"/>
<button id="submit-button" type="submit" pys-onClick="my_function">OK</button>
<div id="test-output"></div>
<py-script>
from js import console
def my_function(*args, **kwargs):
#print('args:', args)
#print('kwargs:', kwargs)
console.log(f'args: {args}')
console.log(f'kwargs: {kwargs}')
text = Element('test-input').element.value
#print('text:', text)
console.log(f'text: {text}')
Element('test-output').element.innerText = text
</py-script>
</body>
</html>
In addition, it would be better if you can also execute the command with ENTER and that you can also rewrite the "textfield_1" as an instruction (what to type in the field)
I would be grateful for any help