I’ve just started using Brython, and am able to receive input from the page and run it through a series of python functions to return a value - but I’m unsure of the correct way to pass these values into a react component. I know nothing about react, and somebody else is doing the react/front side of the website.
The reason we are trying to integrate Brython is because there are a lot of algorithms for manipulating the data that are far easier to write in python, and far quicker to execute in the browser each time the data must be manipulated.
I’m aware of things such as flask and jsonify, but I’m unsure how to use them in this context. I’ve attached a symbolic snippet of Brython code running in browser for reference.
<script type=“text/python” id=“script0”>
from browser import document
from other_python_functions import func1
def return_altered_input(e):
altered_input = func1(e.target.value)
document[‘output’].textContent = altered_input
document[‘input_area’].bind(‘input’, return_altered_input)
</script>
Currently it outputs to the document by referencing the id directly. Could I just put an id on the react element and send the output there somehow? Would I need to jsonify it first?