pythonhtmlweb.py

Trying to create buttons with WebPy, getting a type error


When using The webpy library for python. Im currently trying to make a buttons. Here is my HTML File, Python File and Error.

Code.py - Problem Area

onOff = form.Form(
    form.Button('On'),
    form.Button('Off'),
)

class index:
    def GET(self):
            f = onoff()
            return render.formtest(f)

    def POST(self):
            form = onOff()
            if not form.validates():
                    return render.formtest(form)
            else:
                    return "Great Success!"

formtest.html - Entire Page

$def with (f)

<form name="main" method="post">
$if not form.valid: <p class="error">Try again, American:</p>
$:form.render()
<input type="submit" /> </form>

Error Message-Main Error

<type 'exceptions.TypeError'> at /
GET() takes exactly 1 argument (2 given)

Python  /usr/local/lib/python2.7/dist-packages/web/application.py in                          
handle_class, line 437
Web GET http://192.168.0.34:8080/

Solution

  • The GET method is supposed to accept two parameters, self (the current object) and a url, change it to this

    def GET(self, url):
        f = onoff()
        return render.formtest(f)