【发布时间】:2017-11-01 20:52:09
【问题描述】:
我刚开始使用bottle.py。由于我的应用程序未部署为站点根目录。我将 get_url 用于重定向代码,如下所示:
@myapp.route("/")
def index():
redirect(myapp.get_url("/hello"), name=name)
例如,如果应用程序部署到 http//www.mysite.com/cgi-bin/myapp.py,它将成功重定向到 http//www.mysite.com/cgi-bin/myapp.py/你好
现在的问题是如何重定向到动态路由?例如
@myapp.route("/hello/<name>")
def hello(name):
.....
return template(...)
@myaap.route("/")
def index():
#How to redirect it to /hello/<name>?????
现在我想将页面重定向到路由“/hello/”,但 get_url 不接受它。它不适用于动态路由。
我不会编写自己的“my_get_url”来处理它。我认为每个将瓶子应用程序部署到非根站点的人都应该已经面临并解决了这个问题......
欢迎评论。
谢谢!
【问题讨论】:
-
redirect(myapp.get_url("/hello%s" % name)??