Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.py code:
- from flask import Flask, render_template, request, redirect
- import time
- app = Flask(__name__)
- @app.route("/home")
- def templatehome():
- return render_template("home.html")
- @app.route("/")
- def template():
- return render_template("main.html")
- @app.route("/", methods=["POST"])
- def login():
- information = open("information.txt", "r")
- username = request.form["usr"]
- password = request.form["passw"]
- up = username+":"+password
- if up in information:
- return "logged in"
- else:
- return "not logged in"
- if __name__ == "__main__":
- app.run(debug=True)
- html code:
- <html>
- <head>
- <style>
- h1 {
- text-align: center;
- font-size: 30;
- }
- .buttonlogin[type=submit], input[type=submit] {
- background-color: #4CAF50;
- border: none;
- margin: 16 px 32 px;
- cursor: pointer;
- padding: 16px 20px;
- font-size: 20;
- }
- .textbox[type="username"], input[type="username"] {
- background-color: #42b9f4;
- border: none;
- font-size: 20;
- }
- .textboxpass[type="password"], input[type="password"] {
- background-color: #42b9f4;
- border: none;
- font-size: 20;
- }
- </style>
- </head>
- <h1>
- <form method="POST">
- username <input type="username" name="usr"><br>
- password <input type="password" name="passw"><br>
- <br>
- <input type="submit", value="login">
- </form>
- </h1>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement