Python 如何在web.py中正确处理不同模板中的按钮?

Python 如何在web.py中正确处理不同模板中的按钮?,python,html,raspberry-pi,web.py,Python,Html,Raspberry Pi,Web.py,我正在尝试为我正在进行的raspberry pi项目创建一个简单的web界面 我想要的是一个索引页面,允许我输入三个值,然后单击按钮将它们传递给pi上的另一个程序,该程序使用这些值开始工作。一旦流程启动,web应用程序应转发到第二个页面,显示我刚刚激活的设置。 第二个页面还应该提供一个“停止”按钮,用于停止我之前启动的流程的活动,启动另一个流程并返回索引页面 到目前为止,一切正常,除了我在settings.html上单击“STOP”按钮的部分,我在main.py中得到一个关于第32行的错误,该行

我正在尝试为我正在进行的raspberry pi项目创建一个简单的web界面

我想要的是一个索引页面,允许我输入三个值,然后单击按钮将它们传递给pi上的另一个程序,该程序使用这些值开始工作。一旦流程启动,web应用程序应转发到第二个页面,显示我刚刚激活的设置。 第二个页面还应该提供一个“停止”按钮,用于停止我之前启动的流程的活动,启动另一个流程并返回索引页面

到目前为止,一切正常,除了我在settings.html上单击“STOP”按钮的部分,我在main.py中得到一个关于第32行的错误,该行应该验证index.html字段中输入的值

这是我第一次使用python,我肯定我误解了所有这些应该是如何工作的,但我不知道其他组件何时调用了什么代码

这是我到目前为止得到的代码:

main.py

import web, os
import subprocess
from web import form
render = web.template.render('templates/')

urls = (
        '/(.*)', 'index'
)

valuelimit = form.regexp(r"^-?(0|[1-9]\d*)$",'test')

input_form = form.Form(
        form.Textbox("setting1",    valuelimit, value='50', description="Setting 1"),
        form.Textbox("setting2",    valuelimit, value='70', description="Setting 2"),
        form.Textbox("setting3",  valuelimit, value='5',  description="Setting 3"),
        form.Button("OK", type="submit", description="ok")
)

stop_form = form.Form(
        form.Button("STOP", type="submit", description="ok")
)


class index:
        def GET(self,f):
                f = input_form()
                return render.index(f)

        def POST(self,f):
                f = input_form()
                a = stop_form()
                if not f.validates():
                        return render.valueerror()
                else:
                        subprocess.Popen([start process using Setting 3])
                        subprocess.Popen([start process2 using Setting 1+2])
                        return render.settings(f,a)

class settings:
        def POST(self,a):
                f = input_form()
                subprocess.Popen([stop process2])
                subprocess.Popen([start different process])
                return render.index(f)

if __name__ == "__main__":
        app = web.application(urls, globals())
        app.run()
index.html

$def with(f)

<html>
    <head>
        <title>
            Title
        </title>
    </head>

    <body>
        <center>
            <form method="POST">
                $:f.render()
            </form>
        </center>
    </body>
</html>
$def with(f, a)

<html>
    <head>
        <title>
            Title
        </title>
    </head>

    <body>
        <center>
            Setting 1: $f.setting1.value<br>
            Setting 2: $f.setting2.value<br>
            Setting 3: $f.setting3.value<br>

            <form method="POST">
                $:a.render()
            </form>
        </center>
    </body>
</html>
$def带(f)
标题
$:f.render()
settings.html

$def with(f)

<html>
    <head>
        <title>
            Title
        </title>
    </head>

    <body>
        <center>
            <form method="POST">
                $:f.render()
            </form>
        </center>
    </body>
</html>
$def with(f, a)

<html>
    <head>
        <title>
            Title
        </title>
    </head>

    <body>
        <center>
            Setting 1: $f.setting1.value<br>
            Setting 2: $f.setting2.value<br>
            Setting 3: $f.setting3.value<br>

            <form method="POST">
                $:a.render()
            </form>
        </center>
    </body>
</html>
$def带(f,a)
标题
设置1:$f.设置1.值
设置2:$f.setting2.value
设置3:$f.setting3.value
$:a.render()
您能提供实际错误吗?您能提供实际错误吗?