0
我想重定向我的用戶到另一個域。例如:我的網站是http://www.mysite.com/,我想將它們重定向到http://www.google.com/。金字塔直接用戶到不同域
我希望在表單提交後重定向。這在金字塔web框架中可能嗎?
或者是使用AJAX發佈請求到服務器然後使用javascript重定向的最佳路線?
謝謝。
我想重定向我的用戶到另一個域。例如:我的網站是http://www.mysite.com/,我想將它們重定向到http://www.google.com/。金字塔直接用戶到不同域
我希望在表單提交後重定向。這在金字塔web框架中可能嗎?
或者是使用AJAX發佈請求到服務器然後使用javascript重定向的最佳路線?
謝謝。
在成功提交表單後,將HTTPFound返回到您想要的位置。
from pyramid.httpexceptions import HTTPFound
def form_received_here(request):
# do stuff here
return HTTPFound('http://example.com')
這將返回一個狀態碼302具有報頭Location
設置爲http://example.com
。
啊謝謝,我使用HTTPFound,但位置= request.route_url('http ...')。 – 2012-04-08 21:09:49