mcdona1d / wechat-python-template Goto Github PK
View Code? Open in Web Editor NEW微信公众平台 对接 模板 web.py
微信公众平台 对接 模板 web.py
我按照您的这篇文章一步步操作
http://blog.csdn.net/u010027419/article/details/40835963
在微信测试平台上显示配置成功
sudo python index.py 80
也成功出现了 0.0.0.0:80
但是过了一会就报错了。
在浏览器中点开 公网ip/weixin
也是报错的页面,如下:
<type 'exceptions.AttributeError'> at /weixin
'signature'
Python /usr/local/lib/python2.7/dist-packages/web/utils.py in getattr, line 75
Web GET http://152n011y78.51mypc.cn/weixin
Traceback (innermost first)
/usr/local/lib/python2.7/dist-packages/web/utils.py in getattr
AttributeError: 'a'
"""
def __getattr__(self, key):
try:
return self[key]
except KeyError, k:
raise AttributeError, k ...
def __setattr__(self, key, value):
self[key] = value
def __delattr__(self, key):
try:
▶ Local vars
/home/pi/webpy/raspchat/index.py in _check_hash
urls = (
'/weixin','WeixinInterface'
)
def _check_hash(data):
#sha1加密算法
signature=data.signature ...
timestamp=data.timestamp
nonce=data.nonce
#自己的token
token="wowocccha" #这里改写你在微信公众平台里输入的token
#字典序排序
list=[token,timestamp,nonce]
▼ Local vars
Variable Value
data
<Storage {}>
/home/pi/webpy/raspchat/index.py in GET
self.app_root = os.path.dirname(file)
self.templates_root = os.path.join(self.app_root, 'templates')
self.render = web.template.render(self.templates_root)
def GET(self):
#获取输入参数
data = web.input()
if _check_hash(data): ...
return data.echostr
def POST(self):
str_xml = web.data() #获得post来的数据
xml = etree.fromstring(str_xml)#进行XML解析
content=xml.find("Content").text#获得用户所输入的内容
▼ Local vars
Variable Value
data
<Storage {}>
self
<index.WeixinInterface instance at 0x7601fc38>
/usr/local/lib/python2.7/dist-packages/web/application.py in handle_class
return tocall(*args) ...
▼ Local vars
Variable Value
args
[]
cls
<class index.WeixinInterface at 0x75ff7ed8>
meth
u'GET'
tocall
<bound method WeixinInterface.GET of <index.WeixinInterface instance at 0x7601fc38>>
/usr/local/lib/python2.7/dist-packages/web/application.py in _delegate
raise web.redirect(url)
elif '.' in f:
mod, cls = f.rsplit('.', 1)
mod = import(mod, None, None, [''])
cls = getattr(mod, cls)
else:
cls = fvars[f]
return handle_class(cls) ...
elif hasattr(f, 'call'):
return f()
else:
return web.notfound()
def _match(self, mapping, value):
▶ Local vars
/usr/local/lib/python2.7/dist-packages/web/application.py in handle
def browser(self):
import browser
return browser.AppBrowser(self)
def handle(self):
fn, args = self._match(self.mapping, web.ctx.path)
return self._delegate(fn, self.fvars, args) ...
def handle_with_processors(self):
def process(processors):
try:
if processors:
p, processors = processors[0], processors[1:]
▶ Local vars
/usr/local/lib/python2.7/dist-packages/web/application.py in process
return self.handle() ...
▼ Local vars
Variable Value
process
<function process at 0x757a7030>
processors
[]
self
<web.application.application instance at 0x7604d8f0>
Request information
INPUT
No data.
COOKIES
No data.
META
Variable Value
app_stack
[<web.application.application instance at 0x7604d8f0>]
fullpath
u'/weixin'
headers
[]
home
u'http://152n011y78.51mypc.cn'
homedomain
u'http://152n011y78.51mypc.cn'
homepath
u''
host
u'152n011y78.51mypc.cn'
ip
u'192.168.0.125'
method
u'GET'
output
u''
path
u'/weixin'
protocol
u'http'
query
u''
realhome
u'http://152n011y78.51mypc.cn'
status
'200 OK'
ENVIRONMENT
Variable Value
ACTUAL_SERVER_PROTOCOL
'HTTP/1.1'
HTTP_ACCEPT
'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8'
HTTP_ACCEPT_ENCODING
'gzip, deflate, sdch'
HTTP_ACCEPT_LANGUAGE
'zh-CN,zh;q=0.8'
HTTP_CONNECTION
'keep-alive'
HTTP_HOST
'152n011y78.51mypc.cn'
HTTP_USER_AGENT
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.154 Safari/537.36 LBBROWSER'
PATH_INFO
'/weixin'
QUERY_STRING
''
REMOTE_ADDR
'192.168.0.125'
REMOTE_PORT
'60044'
REQUEST_METHOD
'GET'
REQUEST_URI
'/weixin'
SCRIPT_NAME
''
SERVER_NAME
'localhost'
SERVER_PORT
'80'
SERVER_PROTOCOL
'HTTP/1.1'
SERVER_SOFTWARE
'CherryPy/3.2.0 Server'
wsgi.errors
<open file '', mode 'w' at 0x76d470d0>
wsgi.input
<web.wsgiserver.KnownLengthRFile object at 0x757a4090>
wsgi.multiprocess
False
wsgi.multithread
True
wsgi.run_once
False
wsgi.url_scheme
'http'
wsgi.version
(1, 0)
You're seeing this error because you have web.config.debug set to True. Set that to False if you don't want to see this.
不知道问题出在哪了,还望不吝赐教。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.