Help with beginner form using lpthw.web

pngrv chris.cocuzzo at gmail.com
Sat Oct 15 11:03:21 EDT 2011


Hey -- 

I'm still learning what all of the different exceptions and errors mean. What I'd like to do is grab a bit of assistance figuring out the error I'm getting so that I can keep moving.

My python code for this particular part of the app looks like this:

class rs_request:
    def GET(self):
        return render.rs_request()

    def POST(self):
        form = web.input(name='Dood', project='Awesome', locations='1', engines='1')
        request_string = 'Request: %s, %s, %s, %s' % (form.name, form.project, form.locations, form.engines)
        return render.index(request_string = request_string) 


My HTML:

<html>
 <head>
  <title>Please Use This Form To Request Resources</title>
 </head>
 <body>
 <form action="/rs_request" method="POST">
    Name: <input type="text" name="name"><br/>
    Project: <input type="text" name="project"><br/>
    # of Locations: <input type="text" name="locations"><br/>
    # of Engines: 
    <select name="engines">
     <option value="1">1</option>
     <option value="2">2</option>
     <option value="3">3</option>
     <option value="4">4</option>
     <option value="5">5</option>
     <option value="6">6</option>
     <option value="7">7</option>
     <option value="8">8</option>
     <option value="9+">9+</option>
    </select><br/><br/>
    <input type="submit"><br/><br/>
  </form>
    $def with (request_string)
    $if request_string:
    I just wanted to say <em style="color: green; font-size: 2em;">$request_string</em>.
    $else:
    <em>Hello</em>, world!
 </body>
</html>

And seeing this error:
<type 'exceptions.SyntaxError'> at /rs_request
invalid syntax Template traceback: File 'templates/rs_request.html', line 30 </html> (rs_request.html, line 30)

Python	/Library/Python/2.7/site-packages/web/template.py in compile_template, line 909
Web	GET http://localhost:8080/rs_request

So, it seems to be indicating that my GET request is broken, but I don't really understand why. Can anyone help?



More information about the Python-list mailing list