コンテンツへスキップ
メニュー
この質問にフラグが付けられました
3 返信
23838 ビュー

Hi Guys,

My requirement is to redirect from '/web/login' to homepage (website) if condition is True.

@http.route('/web/login', type='http', auth="none")  
def web_login(self, redirect=None, **kw):
     # ...................
     if condition:
         return werkzeug.utils.redirect('/')

     # ....................


but result is

if not redirect and request.params['login_success']:
KeyError: 'login_success'

and also tried return http.local_redirect('/')

Please help me.

アバター
破棄
最善の回答

Hi you can check this: 




アバター
破棄
最善の回答

if condition TRUE:

      return request.render(module_name.templateID1')  or request.redirect('/')

else:

     return request.render('web.login', values)

     

アバター
破棄
最善の回答

Hi,

"KeyError" comes when dictionary has no key. Use request.params['login_success'] = False to define dict key.
I hope this helps you.

アバター
破棄
関連投稿 返信 ビュー 活動
2
10月 19
11267
0
5月 19
3667
0
6月 19
4277
1
10月 18
6263
2
7月 25
4669