I have a registration form and it should get processed by a function called register_handler() but when the Submit button is pressed, it tries to get to
/register/register_handler() instead of register_handler() which results in a 404 error.
@cherrypy.expose
def register(self):
html = self.get_head('Register')
html += ' </head> <body> <br>'
html += ' <h1 align="center" > Register <h5>'
html += ' <br> <a href="http:/home/"> home </a> '
html += ' <a href="http:/about/"> about </a> <br>'
html += ' <a href="http:/contact/"> contact </a> <br>'
html += '''<p>
</p><table style="border: 1px solid black;">
<form action="register_handler" method="post">
<trstyle="border: 1px solid black;">
<trstyle="border: 1px solid black;"><tr><td align="left"><th align="left">Firstname:</th></td><td><input name="firstname" type="text" value="John"></input></td></tr>
<trstyle="border: 1px solid black;"><tr><td align="left"><th align="left">Lastname:</th></td><td><input name="lastname" type="text" value="Doe"></input></td></tr>
<trstyle="border: 1px solid black;"><tr><td align="left"><th align="left">Email:</th></td><td><input name="email" type="text" value="
elme...@gmail.com"></input></td></tr>
<trstyle="border: 1px solid black;"><tr><td></td><td><th align="center"><input type="submit">Submit!</button></input></td><td></td></tr>
<trstyle="border: 1px solid black;"><tr><td align="left"><th align="left">Password:</th></td><td><input name="password" type="text" value=""></input></td></tr>
</form>
</table>
</body></html> '''
html += ' </html> '
return html
""" The function below handles the register form processing of the above register function."""
@cherrypy.expose
def register_handler(self, Firstname = "John", lastname= 'Doe', email='
joh...@gmail.com'):
print "inside register_handler routine"
cherrypy.log("inside register_handler function")
html = self.get_head()
html += self.get_header_links('register')
print "Firstname:", firstname
print "Lastname:", lastname
print "Email:", email
print "Password:", password
raise cherrypy.HTTPRedirect(cherrypy.url('.'))
# @cherrypy.expose
# def contact(self):
I am not sure how to remove the leading /register/ that gets prepended to the register_handler URL so it results in a 404 and the register_handler function never gets called.