-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmainProcessor.py
35 lines (27 loc) · 890 Bytes
/
mainProcessor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# coding: utf-8
'''
Created on 2013-7-1
@author: xuechong
'''
import webapp2
from Weixin import MsgContent
import logging
import Weixin
from HandlerChain import HandlerChain
class MainProcessor(webapp2.RequestHandler):
def get(self):
param = self.request.get
write = self.response.out.write
self.response.headers['Content-Type'] = 'text/plain'
if Weixin.validate(param):
write(param("echostr"))
else:
write("what's up man -.-?")
def post(self):
if Weixin.validate(self.request.get):
logging.debug(self.request._body__get())
write = self.response.out.write
msg = MsgContent(self.request._body__get())
handlerChain= HandlerChain(userMsg=msg)
write(handlerChain.doChain())
app = webapp2.WSGIApplication([('/weixin', MainProcessor)])