-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
51 lines (47 loc) · 1.49 KB
/
main.py
File metadata and controls
51 lines (47 loc) · 1.49 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
import sqlite3
app=Flask(__name__)
@app.route("/",methods=['GET','POST'])
def home():
return render_template("log.html")
@app.route("/process",methods=['GET','POST'])
def proc():
if request.method=="POST" and 'user' in request.form:
c=0
u=request.form.get('user')
p=request.form.get('password')
con = sqlite3.connect("ntt.db")
cur = con.cursor()
query = "Select name,phnumber from emp"
cur.execute(query)
data = cur.fetchall()
cur.close()
con.close()
for d in data:
if d[0]==u and d[1]==p:
c=1
return render_template("page.html")
else:
c=0
if c==0:
return "INCORRECT LOGIN ATTEMPTED"
@app.route("/register",methods=['GET','POST'])
def ho():
return render_template("reg.html")
@app.route("/reg",methods=['GET','POST'])
def rom():
nu = ""
n = ""
t = ""
f = ""
if request.method == "POST" and 'name' in request.form:
nu = request.form.get('phnumber')
n = request.form.get('name')
t = request.form.get('role')
f = request.form.get('address')
con = sqlite3.connect("ntt.db")
con.execute("Insert into emp('phnumber','name','role','address')values(?,?,?,?)", [nu, n, t, f])
con.commit()
con.close()
return "YOU HAVE REGISTERED SUCESSFULLY ! YOUR NAME AND PHONE NUMBER WILL BE YOUR USERNAME AND PASSWORD"
app.run()