from bottle import route, run, debug, error, request, template
data = request.POST
password = data.get('password')
check_pass = 'password'
if password == check_pass:
My requirement is:
I will get a login and welcome page on same url. Login page has only one password field.
If I get login and go to welcome page again on refreshing, it send me to login page. But ideally it should be on the welcome page only.
My second problem: I want to redirect on a particular url on 404.
If the user goes to the "/home" page, don't you want to check to see if they're logged in before showing them the login screen? It appears like you assume they're not already logged in if the HTTP method is not POST.
I don't know much about your framework, but I assume if the login is successful you should set a cookie, and then you should check the cookie for HTTP GETs to see if the user is authenticated.
Your second question is answered here.
You might also want to take a look at Beaker's cookie sessions and use that to keep your application's state between requests.
If I understand the question correctly, the only way to get to render the welcome template is via POST.
You could change this so that GET requests check whether someone is logged in. If that fails, then redirect them to the login page.