class BookMe(Handler):
def render_book(self, deal=""):
deals = db.GqlQuery("SELECT * FROM Book ORDER BY created DESC")
self.render("book.html", deal=deal,deals = deals)
def get(self):
render_book()
def post(self):
deal = self.request.get("deal")
if deal:
b = Book(deal = deal)
b.put()
self.redirect("/")
app = webapp2.WSGIApplication([('/', MainPage),
('/unit2/rot13', Rot13),
('/book', BookMe),
('/unit2/signup', Unit2Signup),
('/unit2/welcome', Welcome),
('/blog/?', BlogFront),
],debug=True)
我指示'book'映射到BookMe处理程序,但是当我键入/ book时 它会引发404并且/ book与应用程序配置中的任何模式都不匹配。
任何人都可以给我一个提示吗?
这是我的app.yaml
application: byrdnee
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: blog.app
libraries:
- name: jinja2
version: latest
我的主文件名是blog.py
答案 0 :(得分:0)
我没有完整的代码,但以下内容应该有效
import webapp2
from google.appengine.ext.webapp import template
class BookMe(webapp2.RequestHandler):
def get(self):
deals = db.GqlQuery("SELECT * FROM Book ORDER BY created DESC")
template_values = {
'deals': deals,
}
self.response.write(template.render("book.html", template_values))