I just wanted to execute python script in django 2. The python script will communicates with R305 fingerprint scanner. If i pressed a button in webpage, which executes the python script and initiates the sensor.
Need help!
The fastest way to implement this is to use a form post in your template to trigger the script on a button press.
Answer:
def press_my_buttons(request):
if request.POST:
# Run your script here
print("Got the POST request")
return render(request, 'my_template.html')
<form method="post">
{% csrf_token %}
<button type="submit">Press Me!</button>
</form>
Note: While this would get the job done, I would look into trying to use AJAX. Here is a link that could help.