-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.py
More file actions
52 lines (33 loc) · 1.07 KB
/
Copy pathapi.py
File metadata and controls
52 lines (33 loc) · 1.07 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
from flask import Flask,render_template,request,redirect,url_for,session
app = Flask(__name__)
app.secret_key = 'hello'
@app.route("/")
def home():
return render_template('home.html',title = 'home sweet home')
'''@app.route("/layout")
def layout():
return render_template('layout.html')'''
@app.route("/about")
def about():
return render_template('about.html',title = 'about :3')
@app.route("/contacts")
def contacts():
return render_template('contacts.html',title = 'contacts ;)')
@app.route("/login",methods=['GET','POST'])
def login():
if request.method == 'POST':
users = {'user1':'123','user2':'234','user3':'1234','user4':'2345'}
username = request.form['username']
password = request.form['password']
if username not in users:
return "user doesnt exist.gobacc"
if users[username]!=password:
return "password nat matchin"
session['username'] = username
return redirect(url_for('home'))
return redirect(url_for('home'))
@app.route('/logout')
def logout():
session.clear()
return redirect(url_for('home'))
app.run(debug = True)