Advertisement
Guest User

Untitled

a guest
Oct 11th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. app.py code:
  2.  
  3.  
  4. from flask import Flask, render_template, request, redirect
  5. import time
  6.  
  7. app = Flask(__name__)
  8.  
  9. @app.route("/home")
  10. def templatehome():
  11. return render_template("home.html")
  12.  
  13.  
  14. @app.route("/")
  15. def template():
  16. return render_template("main.html")
  17.  
  18. @app.route("/", methods=["POST"])
  19. def login():
  20. information = open("information.txt", "r")
  21. username = request.form["usr"]
  22. password = request.form["passw"]
  23. up = username+":"+password
  24.  
  25. if up in information:
  26. return "logged in"
  27.  
  28. else:
  29. return "not logged in"
  30.  
  31. if __name__ == "__main__":
  32. app.run(debug=True)
  33.  
  34.  
  35. html code:
  36.  
  37.  
  38. <html>
  39. <head>
  40. <style>
  41.  
  42.  
  43. h1 {
  44. text-align: center;
  45. font-size: 30;
  46. }
  47.  
  48. .buttonlogin[type=submit], input[type=submit] {
  49. background-color: #4CAF50;
  50. border: none;
  51. margin: 16 px 32 px;
  52. cursor: pointer;
  53. padding: 16px 20px;
  54. font-size: 20;
  55. }
  56.  
  57. .textbox[type="username"], input[type="username"] {
  58. background-color: #42b9f4;
  59. border: none;
  60. font-size: 20;
  61.  
  62.  
  63. }
  64. .textboxpass[type="password"], input[type="password"] {
  65. background-color: #42b9f4;
  66. border: none;
  67. font-size: 20;
  68. }
  69.  
  70. </style>
  71. </head>
  72.  
  73. <h1>
  74. <form method="POST">
  75.  
  76. username <input type="username" name="usr"><br>
  77. password <input type="password" name="passw"><br>
  78. <br>
  79. <input type="submit", value="login">
  80.  
  81. </form>
  82.  
  83. </h1>
  84.  
  85. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement