app.config['SERVER_NAME'] = "mysite.com"
#工具页蓝图注册,用tool子域名
from .tool import tool as tool_blueprint
app.register_blueprint(tool_blueprint, subdomain='tool')
url_for('tool.index'),就是tool.mysite.com
还有个问题:url_for('static')居然是mysite.com的域名,导致css之类的静态文件全部无法访问
解决办法:自定义static路由,自己加上子域名。
开启SERVER_NAME和sub_domain子域名之后,static需要使用add_url_rule重新自己添加路由
而且要自己添加的static路由生效,必须开头的Flask先将static_folder=None才行,app = Flask(__name__, static_folder=None)
转载于:https://blog.51cto.com/wenguonideshou/2344901