$ sudo /etc/init.d/nginx start #启动nginx
$ sudo rm /etc/nginx/sites-enabled/default #删除默认配置
$ sudo touch /etc/nginx/sites-available/wechat_connector#建立项目文件
$ sudo ln -s /etc/nginx/sites-available/wechat_connector/etc/nginx/sites-enabled/wechat_connector #设置软链接
$ sudo vim /etc/nginx/sites-enabled/wechat_connector #编辑项目文件
添加:
server {
server_name 公网ip;
listen 80;
location /weixin {
proxy_pass http://127.0.0.1:8000;
}
}
最简单的hello world
import werobot
robot = werobot.WeRoBot(token='tokenhere')
# 消息处理函数
@robot.handler
def echo(message):
return 'Hello World!'
robot.run(server="gunicorn", port=8000)