【发布时间】:2013-09-01 22:38:48
【问题描述】:
我想将用户从 test1.domain.com 重定向到 test2.domain.com。我在 url_map 中尝试了“host_matching”以及 url_rule 中的“host”。它似乎不起作用,显示 404 错误。例如,访问 'localhost.com:5000' 时应该转到 'test.localhost.com:5000'。
from flask import Flask, url_for, redirect
app = Flask(__name__)
app.url_map.host_matching = True
@app.route("/")
def hello1():
#return "Hello @ example1!"
return redirect(url_for('hello2'))
@app.route("/test/", host="test.localhost.com:5000")
def hello2():
return "Hello @ test!"
if __name__ == "__main__":
app.run()
有可能吗?有人试过吗? 提前谢谢..
【问题讨论】:
-
这个问题的答案对您的情况有帮助吗? stackoverflow.com/questions/9766134/…