关于使用python搭建微信公众号通过 werobot 自动回复用户消息的问题
希望通过werobot获取用户发来的消息,查询mysql后将结果发送给用户。麻烦各位大神给看看是哪里的问题?
使用的代码如下:
from werobot import WeRoBot
import pymysql
robot = WeRoBot(
token = 'xxxx',
encoding_aes_key = 'xxxx',
app_id = 'xxxx'
)
@robot.text
def echo(message):
conn = pymysql.Connect( host = 'localhost', user = 'xxxx',password = 'xxxx',db = 'xxxx',charset = 'utf8')
cursor = conn.cursor()
cursor.execute("select xxxx from xxxx where name = %s",message.content)
ret = cursor.fetchone()
cursor.close()
conn.close()
return ret
报错的消息为:
Traceback (most recent call last):
File "/xxxx/lib/python3.7/site-packages/flask/app.py", line 2311, in wsgi_app
response = self.full_dispatch_request()
File "/xxxx/lib/python3.7/site-packages/flask/app.py", line 1834, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/xxxx/lib/python3.7/site-packages/flask/app.py", line 1737, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/xxxx/lib/python3.7/site-packages/flask/_compat.py", line 36, in reraise
raise value
File "/xxxx/lib/python3.7/site-packages/flask/app.py", line 1832, in full_dispatch_request
rv = self.dispatch_request()
File "/xxxx/lib/python3.7/site-packages/flask/app.py", line 1818, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/xxxx/lib/python3.7/site-packages/werobot/contrib/flask.py", line 59, in werobot_view
response = make_response(robot.get_encrypted_reply(message))
File "/xxxx/lib/python3.7/site-packages/werobot/robot.py", line 618, in get_encrypted_reply
return reply.render()
AttributeError: 'tuple' object has no attribute 'render'