DOC

googleappengineext

By Hazel Murphy,2014-08-07 10:23
13 views 0
googleappengineext

app.yaml

application: d9423196

    version: 1

    runtime: python api_version: 1

handlers:

- url: /s

     static_dir: s

- url: /main

     script: main.py

     login: required

- url: /get

     script: main.py

     login: required

- url: /del

     script: main.py

     login: required

- url: /del1

     script: main.py

     login: required

- url: /del2

     script: main.py

     login: required

- url: /del3

     script: main.py

     login: required

- url: /del4

     script: main.py

     login: required

- url: /del5

     script: main.py

     login: required

- url: /del6

     script: main.py

     login: required

- url: /del7

     script: main.py

     login: required

- url: /del8

     script: main.py

     login: required

- url: /del9

     script: main.py

     login: required

- url: /comb

     script: main.py

     login: required

    - url: /submit

     script: main.py

     login: required

- url: /.*

     script: welcome.py

main.py

#coding=utf-8

    from datetime import datetime

    from google.appengine.ext import webapp

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

    from google.appengine.ext.webapp import template from google.appengine.api import users

    from google.appengine.api import mail

    import random

class Userif(db.Model):

     user = db.UserProperty(auto_current_user_add=True)

     created = db.DateTimeProperty(auto_now_add=True)

     item1 = db.IntegerProperty(required=True, default=0)

     item2 = db.IntegerProperty(required=True, default=0)

     item3 = db.IntegerProperty(required=True, default=0)

     item4 = db.IntegerProperty(required=True, default=0)

     item5 = db.IntegerProperty(required=True, default=0)

     item6 = db.IntegerProperty(required=True, default=0)

     item7 = db.IntegerProperty(required=True, default=0)

     item8 = db.IntegerProperty(required=True, default=0)

     item9 = db.IntegerProperty(required=True, default=0)

     get1 = db.IntegerProperty(required=True, default=0)

     get2 = db.IntegerProperty(required=True, default=0)

     get3 = db.IntegerProperty(required=True, default=0)

class mainll(webapp.RequestHandler):

     def get(self):

     user = users.get_current_user()

     m = Userif()

     if m.gql("where user = :1 ORDER BY created DESC", user).get():

     u = m.gql("where user = :1 ORDER BY created DESC", user).get()

     if u.get1 == 1 and u.get2 == 1 and u.get3 == 1 :

     content = template.render('back.html',{})

     self.response.out.write(content)

     else:

     greeting = ("<a href=\"%s\"" % users.create_logout_url("/"),)

     x = { 'name' : user,

     'item1' : u.item1,

     'item2' : u.item2,

     'item3' : u.item3,

     'item4' : u.item4,

     'item5' : u.item5,

     'item6' : u.item6,

     'item7' : u.item7,

     'item8' : u.item8,

     'item9' : u.item9,

     'get1' : u.get1,

     'get2' : u.get2,

     'get3' : u.get3,

     'get4' : u.get1 + u.get2 + u.get3,

     }

     content = template.render('main.html',{

     'p' : x,

     'out' : greeting,

     })

     self.response.out.write(content)

     else:

     m.user = user

     m.put()

     user = users.get_current_user()

     u = Userif.gql("where user = :1 ORDER BY created DESC", user).get()

     u.item1 = random.randint(1, 12)

     u.item2 = random.randint(1, 12)

     u.item3 = random.randint(1, 12)

     u.put()

     content = template.render('first.html',{ })

     self.response.out.write(content)

class getpage(webapp.RequestHandler):

     def get(self):

     user = users.get_current_user()

     u = Userif.gql("where user = :1 ORDER BY created DESC", user).get()

     if u.item1 == 0 :

     u.item1 = random.randint(1, 12)

     u.put()

     self.redirect('/main')

     else:

     if u.item2 == 0 :

     u.item2 = random.randint(1, 12)

     u.put()

     self.redirect('/main')

     else:

     if u.item3 == 0 :

     u.item3 = random.randint(1, 12)

     u.put()

     self.redirect('/main')

     else:

     if u.item4 == 0 :

     u.item4 = random.randint(1, 12)

     u.put()

     self.redirect('/main')

     else:

     if u.item5 == 0 :

     u.item5 = random.randint(1, 12)

     u.put()

     self.redirect('/main')

     else:

     if u.item6 == 0 :

     u.item6 = random.randint(1, 12)

     u.put()

     self.redirect('/main')

     else:

     if u.item7 == 0 :

     u.item7 = random.randint(1, 12)

     u.put()

     self.redirect('/main')

     else:

     if u.item8 == 0 :

     u.item8 = random.randint(1, 12)

     u.put()

     self.redirect('/main')

     else:

     if u.item9 == 0 :

     u.item9 = random.randint(1, 12)

     u.put()

     self.redirect('/main')

     else:

     self.redirect('/main')

    class delpage1(webapp.RequestHandler):

     def get(self):

     user = users.get_current_user()

     u = Userif.gql("where user = :1 ORDER BY created DESC", user).get()

     u.item1 = 0

     u.put()

     self.redirect('/main') class delpage2(webapp.RequestHandler):

     def get(self):

     user = users.get_current_user()

     u = Userif.gql("where user = :1 ORDER BY created DESC", user).get()

     u.item2 = 0

     u.put()

     self.redirect('/main') class delpage3(webapp.RequestHandler):

     def get(self):

     user = users.get_current_user()

     u = Userif.gql("where user = :1 ORDER BY created DESC", user).get()

     u.item3 = 0

     u.put()

     self.redirect('/main') class delpage4(webapp.RequestHandler):

     def get(self):

     user = users.get_current_user()

     u = Userif.gql("where user = :1 ORDER BY created DESC", user).get()

     u.item4 = 0

     u.put()

     self.redirect('/main') class delpage5(webapp.RequestHandler):

     def get(self):

     user = users.get_current_user()

     u = Userif.gql("where user = :1 ORDER BY created DESC", user).get()

     u.item5 = 0

     u.put()

     self.redirect('/main') class delpage6(webapp.RequestHandler):

     def get(self):

     user = users.get_current_user()

     u = Userif.gql("where user = :1 ORDER BY created DESC", user).get()

     u.item6 = 0

     u.put()

     self.redirect('/main') class delpage7(webapp.RequestHandler):

     def get(self):

     user = users.get_current_user()

     u = Userif.gql("where user = :1 ORDER BY created DESC", user).get()

     u.item7 = 0

     u.put()

     self.redirect('/main') class delpage8(webapp.RequestHandler):

     def get(self):

     user = users.get_current_user()

     u = Userif.gql("where user = :1 ORDER BY created DESC", user).get()

     u.item8 = 0

     u.put()

     self.redirect('/main') class delpage9(webapp.RequestHandler):

     def get(self):

     user = users.get_current_user()

     u = Userif.gql("where user = :1 ORDER BY created DESC", user).get()

     u.item9 = 0

     u.put()

     self.redirect('/main') class delpage(webapp.RequestHandler):

     def get(self):

     user = users.get_current_user()

     u = Userif.gql("where user = :1 ORDER BY created DESC", user).get()

     u.item1 = 0

     u.item2 = 0

     u.item3 = 0

     u.item4 = 0

     u.item5 = 0

     u.item6 = 0

     u.item7 = 0

     u.item8 = 0

     u.item9 = 0

     u.get1 = 0

     u.get2 = 0

     u.get3 = 0

     u.put()

     self.redirect('/main')

    class comb(webapp.RequestHandler):

null

     if L1[4:8] == [1,1,1,1]:

     for t in range (0,9):

     if L[t] == 5 :

     L[t] = 0

     break

     for t in range (0,9):

     if L[t] == 6 :

     L[t] = 0

     break

     for t in range (0,9):

     if L[t] == 7 :

     L[t] = 0

     break

     for t in range (0,9):

     if L[t] == 8 :

     L[t] = 0

     break

     u.item1 = L[0]

     u.item2 = L[1]

     u.item3 = L[2]

     u.item4 = L[3]

     u.item5 = L[4]

     u.item6 = L[5]

     u.item7 = L[6]

     u.item8 = L[7]

     u.item9 = L[8]

     u.get2 = 1

     u.put()

     self.redirect('/main')

     else:

     if L1[8:12] == [1,1,1,1]:

     for t in range (0,9):

     if L[t] == 9 :

     L[t] = 0

     break

     for t in range (0,9):

     if L[t] == 10 :

     L[t] = 0

     break

     for t in range (0,9):

     if L[t] == 11 :

     L[t] = 0

     break

     for t in range (0,9):

     if L[t] == 12 :

     L[t] = 0

     break

     u.item1 = L[0]

     u.item2 = L[1]

     u.item3 = L[2]

     u.item4 = L[3]

     u.item5 = L[4]

     u.item6 = L[5]

     u.item7 = L[6]

     u.item8 = L[7]

     u.item9 = L[8]

     u.get3 = 1

     u.put()

     self.redirect('/main')

     else:

     self.redirect('/main')

class submit(webapp.RequestHandler):

     def post(self):

     comment = self.request.get('comment', '')

     user = users.get_current_user()

     u = Userif.gql("where user = :1 ORDER BY created DESC", user).get()

     u.delete()

     sender = 'd9423196@gmail.com'

     recipient = '%s@gmail.com' % user

     subject = '漂流瓶:恭喜您成功返回家鄉'

     body = """

     Here is your wish.

     %s

     Small fish may bless you.

     See you next time.

     http://d9423196.appspot.com/

     Welcome back.

     """ % comment

     mail.send_mail(sender, recipient, subject, body, )

Report this document

For any questions or suggestions please email
cust-service@docsford.com