if __name__ == '__main__': app.run(host='0.0.0.0', threaded=True)
用 Apache 部署起来
在项目根目录下新建一个 wsgi 文件,写入配置,修改成你的部署目录:
1 2 3 4 5 6 7 8
#! /usr/bin/python3.6
import logging import sys logging.basicConfig(stream=sys.stderr) sys.path.insert(0, '/var/www/seeyoubot') # Your own deploy path from server import app as application application.secret_key = 'just_a_secret_key'# Anything you want
<VirtualHost *:80> # Add machine's IP address or your subdomain ServerName yourserver.com # Give an alias to to start your website url with WSGIScriptAlias / /var/www/seeyoubot/seeyoubot.wsgi <Directory /var/www/seeyoubot/> # set permissions as per apache2.conf file Options FollowSymLinks AllowOverride None Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
接下来 service apache2 restart,回到微信公众平台点击提交,你应该已经可以提交成功了。现在你可以专注于处理回复消息的逻辑了。