google app engine 快速留言板!

還有錯誤~修正中
期許成為一個超快速留言功能~

import cgi
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class Comment(db.Model):
  author = db.StringProperty
  content = db.StringProperty
  data = db.DateTimeProperty(auto_now_add=True)

class CommentBook(webapp.RequestHandler):
  def post(self):
    comment = Comment()
    comment.author = self.request.get('author')
    comment.content = self.request.get('content')
    comment.put()
    self.redirect('/')

class MainPage(webapp.RequestHandler):
  def get(self):
    self.response.out.write('')

    commentings = db.GqlQuery("SELECT * FROM Comment")

    for commenting in commentings:
      if commenting.author:
        self.response.out.write('%s →:' % commenting.author)
      else:
        self.response.out.write('somebody →:')
      self.response.out.write('
%s
' % commenting.content) # Write the submission form and the footer of the page self.response.out.write(""" → """) application = webapp.WSGIApplication( [('/', MainPage), ('/sign', CommentBook)], debug=True) def main(): run_wsgi_app(application) if __name__ == "__main__": main()