我正在尝试在HTML中使用复选框,将这些复选框返回到我的Python后端,然后如果单击框,则递增三个计数器。
目前我的HTML如下所示,并且运行良好:
<form method="post">
<input type="checkbox inline" name="adjective" value="entertaining">Entertaining
<input type="checkbox inline" name="adjective" value="informative">Informative
<input type="checkbox inline" name="adjective" value="exceptional">Exceptional
</form>
然后在我的Python后端中,我有以下代码:
def post(self):
adjective = self.request.get('adjective ')
if adjective :
#somehow tell if the entertaining box was checked
#increment entertaining counter
#do the same for the others
print形容词
来查看里面的内容,对吧?它将与你的HTML混合在一起,但你可以通过查看源代码来查看... - kindallwebapp
还是webapp2
?它们在从请求中获取多个值方面具有略微不同的 API。 - Blckknght