Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

flask login

def login():
    if request.method == 'GET':
        return '''
               <form method='POST'>
                <input type='text' name='username' id='username' placeholder='username'></input>
                <input type='password' name='password' id='password' placeholder='password'></input>
                <input type='submit' name='submit'></input>
               </form>
               '''

    username = (await request.form)['username']
    password = (await request.form)['password']
    if username in users and compare_digest(password, users[username]['password']):
        user = User()
        user.id = username
        flask_login.login_user(user)
        return redirect(url_for('protected'))

    return 'Bad login'
Source by www.programcreek.com #
 
PREVIOUS NEXT
Tagged: #flask #login
ADD COMMENT
Topic
Name
4+6 =