Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
23737 Vistas

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
Descartar
Mejor respuesta

Hi you can check this: 




Avatar
Descartar
Mejor respuesta

if condition TRUE:

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

else:

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

     

Avatar
Descartar
Mejor respuesta

Hi,

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

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
oct 19
11205
0
may 19
3606
0
jun 19
4231
1
oct 18
6208
2
jul 25
4516