forked from karmalk/RASA_Wechat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·48 lines (43 loc) · 1.27 KB
/
main.py
File metadata and controls
executable file
·48 lines (43 loc) · 1.27 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import web
import hashlib
# import receive
# import replay
from handle import Handle
urls = (
'/wx', 'Handle',
)
'''
# 改get请求用于验证Token
class Handle(object):
def GET(self):
return " hello 测试成功"
def GET(self):
try:
data = web.input()
print(data)
if len(data) == 0:
return "hello, this is handle view"
signature = data.signature
timestamp = data.timestamp
nonce = data.nonce
echostr = data.echostr
token = "KarmaLK" #请按照公众平台官网\基本配置中信息填写
li = [token, timestamp, nonce]
li.sort()
tmp_str = "".join(li).encode('utf-8')
#进行sha1加密
hashcode = hashlib.sha1(tmp_str).hexdigest()
#sha1 = hashlib.sha1()
#map(sha1.update, li)
#hashcode = sha1.hexdigest()
print("handle/GET func: hashcode, signature: ", hashcode, signature)
if hashcode == signature:
return echostr
else:
return ""
except Exception as Argument:
return Argument
'''
if __name__ == '__main__':
app = web.application(urls, globals())
app.run()