http://me-for-president.appspot.com/item/1
in the code
class ItemPage(webapp.RequestHandler):
def get(self, id):
id = int(id)
# rest of the handler
application = webapp.WSGIApplication([('/item/(\d+)', ItemPage)],
debug=True)
def main():
run_wsgi_app(application)
Use some sort of template engine. Much easier if the site or pages gets bigger.
class ItemIndexPage(webapp.RequestHandler):
def get(self):
items = Item.all().filter(...some filter...).fetch(1000)
self.response.out.write("<ol>")
for item in items:
self.response.out.write("""<li><a href="%s">%s</a><br />
<a href="/item/%s">comments</a></li> """ %
(cgi.escape(item.url),
cgi.escape(item.title), cgi.escape(item.key().id())))
self.response.out.write("</ol>")
And deal with the individual item in the next handler
class ItemPage(webapp.RequestHandler):
def get(self, id):
id = int(id)
item = Item.get_by_id(id)
# rest of the handler
application = webapp.WSGIApplication([('/items',
ItemIndexPage)],('/item/(\d+)', ItemPage)],
debug=True)
--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.