i want to go from one page to another in my website using a button. my code for this is like the following:
self.response.out.write('''<form
action="/sign" method=post> <br><input type=submit value="go to lesson 2 ">
</form>
''') % self.redirect("/lesson1")
开发者_如何学JAVAnow i am in lesson one page and i want using this button to go to lesson1 page but i keep getting this error: PyDev breakpoint inconsistent dedent at line 53, column 2 Bad Indentation (7 spaces)
does any one know how to fix this?
thanks Amal
Aside from bad indentation and an errant attempt at using %
, self.redirect(...)
is done for effect, not to get a string you can use to embed elsewhere. What you've got it more properly divided into a get
handler (to emit the form) and a post
handler to do the redirect.
An alternative is to do the redirect in the browser, using JavaScript.
I got the correct answer using html.
I have two pages inside my website in google app engine and they are:
lesson1.py
lesson2.py
to go from lesson one to lesson using a button i put this code inside lesson1.py:
self.response.out.write('''<form action="/lesson2" method="get">
<input type="submit" value="go to lesson2" />
</form> ''')
application = webapp.WSGIApplication([('/', MainHandler)], debug=True)
application = webapp.WSGIApplication([('/lesson1', MainHandler)],debug = True)
then in lesson2.py where i want to go i put this code:
application = webapp.WSGIApplication([('/', MainHandler)], debug=True)
application = webapp.WSGIApplication([('/lesson2', MainHandler)],debug = True)
an important issue is the app.yaml file mine looks like this:
application: Sign-language version: 1
runtime: python
api_version: 1
handlers:
- url: /lesson2
script: lesson2.py
- url: /.*
script: lesson1.py
Use Preferences->Pydev->Editor and uncheck replace tabs with spaces. Tabs can be 4 spaces despite popular opinion that it should be changed to 8 spaces.
精彩评论