Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
3 Replies
23596 Tampilan

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.

Avatar
Buang
Jawaban Terbai

Hi you can check this: 




Avatar
Buang
Jawaban Terbai

if condition TRUE:

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

else:

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

     

Avatar
Buang
Jawaban Terbai

Hi,

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

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
2
Okt 19
11077
0
Mei 19
3503
0
Jun 19
4092
1
Okt 18
6078
2
Jul 25
4181