I am trying to make some python scripts on google appspot. I am just starting with python so I don’t now verry much about it.
I am using the example code you can find on the google appspot documentations. But whenever I submit the form in this code, I just get an blank page and no errors. Anyone knows why?
import cgi
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
class MainPage(webapp.RequestHandler):
def get(self):
p = self.request.get("p", default_value="25")
self.response.out.write("""
<html>
<body>
<form action="/" method="post">
The first <input type="text" name="p" value=""" + p + """ style="width: 35px;text-align:center;"> fibionacci numbers:<br />""")
p = int(p)
a, b = 0, 1
while p > 0:
self.response.out.write(str(b) + " ")
a, b = b, a+b
p = p - 1
self.response.out.write("""
</form>
</body>
</html>""")
application = webapp.WSGIApplication([('/', MainPage)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
Thank you in advance.
WOAH
If you’re using google app engine (hosted on appspot so I’m sure that’s what you’re using) then you use this:
If you’ve set up your handler like this then it will automagically work:
That will work for both GET and POST variables.