我添加了子域支持:
127.0.0.1 subdomain.test.com
SERVER_NAME = 'test.com:5005'
@app_blueprint.route('/', methods=['GET'], subdomain='<subdomain_name>')
def index(subdomain_name):
return redirect(url_for('app.index'))
它成功找到了路线,但是当它将模板app.html加载到浏览器中时,它无法解析静态资源:
代替
<script src="http://subdomain.test.com:5005/static/dist/app.bundle.js"></script>
它解析为
<script src="http://test.com:5005/static/dist/app.bundle.js"></script>
并且找不到它。
我想念什么?
更新。我根据肖恩的答案更新了主机文件。但是现在Flask找不到我重定向到的端点“ app.index”。
我指定为:
@app_blueprint.route('/app', methods=['GET'], subdomain='<subdomain_name>')
@app_blueprint.route('/app/<path:path>', methods=['GET'], subdomain='<subdomain_name>')
def index(path = None, subdomain_name=None):
return render_template('app.html', subdomain_name=subdomain_name)
如果我直接在浏览器中使用/ app,但无法重定向,并且也找不到其他东西,则可能会击中该endpoind。
127.0.0.1 subdomain.test.com test.com
[您告诉Flask您已安装在test.com
,因此它已将/static
路由安装在了那里...但是您的网络层不知道test.com
在哪里,因为您没有告诉它在哪里。