I am building a web interface using Django and want to run some code of python on button click event of bootstrap button. I want to know in which python file should I write that code and how to call that function.
The code I am trying to run is using subProcess module of python to run a command on terminal and get error and output streams. The code it self is working fine in python 3.7 but I don't know how to call that code on button click. I am using django for the first time.
<button type="button" class="btn btn-primary" name="sra" onclick="myFunction()">Primary</button>
<script>
function myFunction(){
#this is the part where I am stuck
}
</script>