from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
class Greeting(db.Model):
author = db.UserProperty()
content = db.StringProperty(multiline=True)
date = db.DateTimeProperty(auto_now_add=True)
class MainPage(webapp.RequestHandler):
def get(self):
self.response.out.write('')
greetings = db.GqlQuery("SELECT * FROM JPDBinfo ORDER BY date DESC LIMIT 10")
for greeting in greetings:
if greeting.author:
self.response.out.write('%s wrote:' % greeting.author.nickname())
else:
self.response.out.write('An anonymous person wrote:')
self.response.out.write('
%s' %
cgi.escape(greeting.content))
self.response.out.write("""
//* YOUR OWN HTML CODE
class Guestbook(webapp.RequestHandler):
def post(self):
greets = Pagabati()
if users.get_current_user():
greets.author = users.get_current_user()
greets.content = self.request.get('content')
greets.put()
self.redirect('/')
application = webapp.WSGIApplication(
[('/', UnangPahina),
('/sign', Lakdaan)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
Note:
After compile the code and save do the following:
Go -> Application - Terminal
Type the command
/* compile the python file that you created and compile by Google App Engine
chmod u+x progname.py
run the script
./programko.py
No comments:
Post a Comment