我在使用数据存储区发布简单表单时遇到问题。我只是试图存储RSS提要,从名称(sourceName)和链接(sourceLink)开始。表单加载,我可以在两个字段中输入文本,但是当我点击提交时,我收到404错误。我非常接近留言簿教程,所以我有点沮丧。这是表单代码:
import cgi
import urllib
#from google.appengine.api import users
from google.appengine.ext import ndb
import webapp2
MAIN_PAGE_FOOTER_TEMPLATE = """\
<form action="/newURL%s" enctype="multipart/form-data" method="post">
<div><textarea name="sourceName" rows="1" cols="60"></textarea></div>
<div><textarea name="sourceLink" rows="1" cols="60"></textarea></div>
<div><input type="submit" value="Submit"></div>
</form>
<hr>
</body>
</html>
"""
以下是其余部分,不包括MainPage代码,它似乎正常加载。
class Feedlist(webapp2.RequestHandler):
def post(self):
feedlist_name = self.request.get('feedlist_name',
DEFAULT_FEEDLIST_NAME)
feed = RSSFeed(parent=feedlist_key(feedlist_name))
feed.sourceName = self.request.get('sourceName')
feed.sourceLink = self.request.get('sourceLink')
feed.put()
query_params = {'feedlist_name': feedlist_name}
self.redirect('/?' + urllib.urlencode(query_params))
app = webapp2.WSGIApplication([
('/RSSFeeds', MainPage),
('/newURL', Feedlist)], debug=True)
YAML:
application: myrssapp
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /updateRSS/daily
script: updateRSS.app
login: admin
- url: /searchQuery
script: searchQuery.app
- url: /RSSFeeds
script: RSSSources.app
- url: /newURL
script: RSSSources.app
- url: /.*
script: searchQuery.app
我已经尝试过在yaml中包含newURL而不包括它。
来自日志:
"POST /newURL%s HTTP/1.1" 404 188 "http://myrssapp.appspot.com/RSSFeeds