[英]how to execute python script in django framework?
我只是想在 django 2 中执行 python 脚本。 python 脚本将与 R305 指纹扫描仪通信。 如果我按下网页中的一个按钮,它会执行 python 脚本并启动传感器。
需要帮助!
实现这一点的最快方法是在模板中使用表单帖子来触发按钮按下时的脚本。
回答:
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>
注意:虽然这可以完成工作,但我会考虑尝试使用 AJAX。 这是一个可以提供帮助的链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.