使用 Google App Engine 时如何将表单数据编码到 url?
下面的代码会生成一个表单,您可以在其中输入一些文本。然后文本显示在另一页上"/sign"
而不是指向/sign
我想指向/sign?message="hello"
这是我的代码,来自这里:https ://developers.google.com/appengine/docs/python/gettingstartedpython27/handlingforms )
import cgi
import webapp2
from google.appengine.api import users
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.out.write("""
<html>
<body>
<form action="/sign" method="post">
<div><textarea name="content" rows="3" cols="60"></textarea></div>
<div><input type="submit" value="Sign Guestbook"></div>
</form>
</body>
</html>""")
class Guestbook(webapp2.RequestHandler):
def post(self):
self.response.out.write('<html><body>You wrote:<pre>')
self.response.out.write(cgi.escape(self.request.get('content')))
self.response.out.write('</pre></body></html>')
app = webapp2.WSGIApplication([('/', MainPage),
('/sign', Guestbook)],
debug=True)