0

我想将我的用户重定向到另一个域。例如:我的网站是http://www.mysite.com/我想将它们重定向到http://www.google.com/

我希望重定向在表单提交之后进行。在金字塔网络框架中这可能吗?

或者是使用 AJAX 发布请求到服务器然后使用 javascript 重定向的最佳途径?

谢谢你。

4

1 回答 1

2

成功提交表单后返回 HTTPFound 与您想要的位置。

from pyramid.httpexceptions import HTTPFound

def form_received_here(request):
    # do stuff here
    return HTTPFound('http://example.com')

这将返回一个状态码 302,其Location标头设置为http://example.com.

于 2012-04-06T22:38:05.213 回答