[英]How do I link a button in html with my python code? (django)
我正在使用 django 并且我想根据用户在我页面的选择框中放置的内容来计算一些东西,但我不知道如何将它与计算所有内容的 python 代码连接起来,请帮助:(
您可以通过方法 post 和 action="path_of_your_python_file" 使用 html 表单元素
<form name="search" action="calculate.py" method="GET">
Search: <input type="checkbox" name="user_input">
<input type="submit" value="Submit">
</form>
然后在calculate.py
import cgi
form = cgi.FieldStorage()
searchterm = form.getvalue('user_input')
// Do your calculation here
我认为这会有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.