Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from bottle import Bottle,route,run
- from bottle import get, post, request
- app = Bottle()
- usernames = ["username", "user"]
- passwords = ["password", "pass"]
- def check_login(username, password):
- if username in usernames and password in passwords:
- return True
- else:
- return False
- @app.route('/')
- @app.route('/hello')
- def hello():
- return "Hellowwwwww!"
- @app.route('/login')
- def login():
- return '''
- <form action="/login" method="post">
- Username: <input name="username" type="text" />
- Password: <input name="password" type="password" />
- <input value="Login" type="submit" />
- </form>
- '''
- @app.post('/login')
- def login():
- username = request.forms.get('username')
- password = request.forms.get('password')
- if check_login(username, password) is True:
- return "<p>Your login information was correct.</p>"
- else:
- return "<p>Login failed.</p>"
- run(app, host='localhost', port=9000, debug=True)
Add Comment
Please, Sign In to add comment