-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp1.py
39 lines (29 loc) · 1.06 KB
/
app1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from flask import Flask, render_template, request, redirect, url_for, session
app = Flask(__name__)
app.secret_key = 'your_secret_key'
@app.route("/b")
def b1():
return render_template("home2.html")
userss = {"Pramod": "di@1234", "dis": "dis@1234", "disi": "disi@1234"}
@app.route("/c")
def b2():
return render_template("home2.html")
@app.route("/login", methods=['POST', 'GET'])
def login():
if request.method == 'POST':
username = request.form['username']
password = request.form['password']
if username in userss and userss[username] == password:
session["user"] = username
return redirect(url_for('b2'))
else:
return "Invalid details. Try again with correct details."
elif "user" in session:
return redirect(url_for('b2'))
return render_template("login.html")
@app.route("/logout", methods=["POST"])
def logout():
session.pop("user", None)
return redirect(url_for('login'))
if __name__ == "__main__":
app.run(debug=True)