【问题标题】:how to execute python script in django framework?如何在 django 框架中执行 python 脚本?
【发布时间】:2018-02-10 03:11:36
【问题描述】:

我只是想在 django 2 中执行 python 脚本。python 脚本将与 R305 指纹扫描仪通信。如果我按下网页中的按钮,该按钮将执行 python 脚本并启动传感器。

需要帮助!

【问题讨论】:

  • 取决于脚本。

标签: python django python-3.x fingerprint


【解决方案1】:

实现这一点的最快方法是在模板中使用表单帖子来触发按钮按下时的脚本。

答案:

views.py

​​>
def press_my_buttons(request):
    if request.POST:
        # Run your script here
        print("Got the POST request")
    return render(request, 'my_template.html')

my_template.html

<form method="post">
    {% csrf_token %}
    <button type="submit">Press Me!</button>
</form>

注意:虽然这样可以完成工作,但我会考虑尝试使用 AJAX。 这是一个link,可以提供帮助。

【讨论】:

  • 把python文件传到哪里??以及如何??
猜你喜欢
  • 2016-08-09
  • 2017-06-25
  • 2018-12-25
  • 1970-01-01
  • 2023-03-23
  • 2020-03-23
  • 2016-07-29
  • 1970-01-01
  • 2010-12-28
相关资源
最近更新 更多