Reputation: 75
Working through LPTHW exercise 51 and hit a wall. Trying to get some basic user input through a browser and then display it. Code is as follows - first python:
import web
urls = (
'/', 'Index'
)
app = web.application(urls, globals())
render = web.template.render('templates/')
class Index(object):
def GET(self):
return render.hello_form()
def POST(self):
form = web.input(name="Nobody", greet="Hello")
greeting = "%s, %s" % (form.greet, form.name)
return render.index(greeting = greeting)
if __name__ == "__main__":
app.run()
Then the HTML:
<html>
<head>
<title>Sample web form</title>
</head>
<body>
<h1>Fill out this form</h1>
<form action="/hello" method="POST">
A Greeting: <input type="text" name="greet">
<br/>
Your Name: <input type="text" name="name">
<br/>
<input type="submit">
</form>
</body>
</html>
When I click "submit" the only thing I get back is "not found".
Upvotes: 1
Views: 1303
Reputation: 21
You have missed something important in your code in the Python file.
You should write this :
urls = (
'/hello', 'Index'
instead of this :
urls = (
'/', 'Index' ...
Upvotes: 1