Example #1
0
 def post(self):
     send = self.request.get("send")
     rec = self.request.get("rec")
     mess = self.request.get("mess")
     friend=User.query(User.uName==send).get()
     friend.flag=True
     friend.put()
     newMessage=Message(sender=send,receiver=rec,message=mess)
     newkey=newMessage.put()
     message=Message.query(ndb.OR(ndb.AND(Message.receiver==rec,Message.sender==send),ndb.AND(Message.receiver==send,Message.sender==rec))).order(Message.timestamp).fetch(40)
     response='Message Send Success!'
     # for m in message:
     #     response+=m.str()+'\n'
     self.response.write(response)
Example #2
0
 def post(self):
     send = self.request.get("send")
     rec = self.request.get("rec")
     mess = self.request.get("mess")
     friend = User.query(User.uName == send).get()
     friend.flag = True
     friend.put()
     newMessage = Message(sender=send, receiver=rec, message=mess)
     newkey = newMessage.put()
     message = Message.query(
         ndb.OR(ndb.AND(Message.receiver == rec, Message.sender == send),
                ndb.AND(Message.receiver == send,
                        Message.sender == rec))).order(
                            Message.timestamp).fetch(40)
     response = 'Message Send Success!'
     # for m in message:
     #     response+=m.str()+'\n'
     self.response.write(response)
Example #3
0
            pwd='123',
            friend=['Tom', 'Jerry', 'Emma'])
emma = User(id='*****@*****.**',
            uName='Emma',
            email='*****@*****.**',
            pwd='123',
            friend=['Tom', 'Lucy', 'Jerry'])
tom.put()
jerry.put()
lucy.put()
emma.put()
#init Message
m1 = Message(sender="Jerry", receiver="Tom", message="hello tom!")
m2 = Message(sender="Tom", receiver="Jerry", message="Hi Jerry! what's up?")
m3 = Message(sender="Tom", receiver="Emma", message="Hi Emma! what's up?")
key_m1 = m1.put()
# print('call put')
key_m2 = m2.put()
# print('call put')
key_m3 = m3.put()


# print('call put')
#handeler
class MainHandler(webapp2.RequestHandler):
    def get(self):
        template = JINJA_ENVIRONMENT.get_template('index.html')
        self.response.write(template.render())


class SignUpHandler(webapp2.RequestHandler):
Example #4
0
JINJA_ENVIRONMENT = jinja2.Environment(
    loader=jinja2.FileSystemLoader([os.path.dirname(__file__),os.path.dirname(__file__)+"/templates"]))
#init User
tom=User(id='*****@*****.**',uName='Tom',email='*****@*****.**',pwd='123',friend=['Jerry','Lucy','Emma'])
jerry=User(id='*****@*****.**',uName='Jerry',email='*****@*****.**',pwd='123',friend=['Tom','Lucy','Emma'])
lucy=User(id='*****@*****.**',uName='Lucy',email='*****@*****.**',pwd='123',friend=['Tom','Jerry','Emma'])
emma=User(id='*****@*****.**',uName='Emma',email='*****@*****.**',pwd='123',friend=['Tom','Lucy','Jerry'])
tom.put()
jerry.put()
lucy.put()
emma.put()
#init Message
m1=Message(sender="Jerry",receiver="Tom",message="hello tom!")
m2=Message(sender="Tom",receiver="Jerry",message="Hi Jerry! what's up?")
m3=Message(sender="Tom",receiver="Emma",message="Hi Emma! what's up?")
key_m1=m1.put()
# print('call put')
key_m2=m2.put()
# print('call put')
key_m3=m3.put()
# print('call put')
#handeler
class MainHandler(webapp2.RequestHandler):
    def get(self):
        template = JINJA_ENVIRONMENT.get_template('index.html')
        self.response.write(template.render())

class SignUpHandler(webapp2.RequestHandler):
    def get(self):
        template = JINJA_ENVIRONMENT.get_template('signup.html')
        self.response.write(template.render())