Skip to content

Instantly share code, notes, and snippets.

Created Jul 8, 2016
What would you like to do?
from bottle import route, run, request
import os
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" />
@route("/login", method="POST")
def do_login():
username = request.forms.get("username")
password = request.forms.get("password")
if check_login(username, password):
return "<p>Your ligin infomation was correct.</p>"
return "<p>Login failed.</p>"
def check_login(username, password):
if username == "user" and password == "pass":
return True
return False
run(host="", port=int(os.environ.get("PORT", 5000)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment