Advertisement
Guest User

Untitled

a guest
Jul 8th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. from bottle import route, run, request
  2. import os
  3.  
  4. @route("/login")
  5. def login():
  6. return """
  7. <form action="/login" method="post">
  8. Username: <input name="username" type="text" />
  9. Password: <input name="password" type="password" />
  10. <input value="Login" type="submit" />
  11. </form>
  12. """
  13.  
  14. @route("/login", method="POST")
  15. def do_login():
  16. username = request.forms.get("username")
  17. password = request.forms.get("password")
  18. if check_login(username, password):
  19. return "<p>Your ligin infomation was correct.</p>"
  20. else:
  21. return "<p>Login failed.</p>"
  22.  
  23. def check_login(username, password):
  24. if username == "user" and password == "pass":
  25. return True
  26. else:
  27. return False
  28.  
  29. run(host="0.0.0.0", port=int(os.environ.get("PORT", 5000)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement