-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublic.py
More file actions
60 lines (54 loc) · 1.92 KB
/
public.py
File metadata and controls
60 lines (54 loc) · 1.92 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
52
53
54
55
56
57
58
59
60
from flask import *
from database import *
public=Blueprint('public',__name__)
@public.route('/')
def home():
return render_template('index.html')
@public.route('/login',methods=['get','post'])
def login():
if 'login' in request.form:
uname=request.form['uname']
pwd=request.form['pwd']
q="select * from login where username='%s' and password='%s'"%(uname,pwd)
res=select(q)
if res:
session['login_id']=res[0]['login_id']
if res[0]['user_type']=='phc':
q="select * from phc where login_id='%s'"%(session['login_id'])
res1=select(q)
if res1:
session['phc_id']=res1[0]['phc_id']
return redirect(url_for('phc.phc_home'))
if res[0]['user_type']=='ashaworker':
q="select * from ashaworker where login_id='%s'"%(session['login_id'])
res1=select(q)
if res1:
session['ashaworker_id']=res1[0]['ashaworker_id']
return redirect(url_for('ashaworker.ashaworkerhome'))
if res[0]['user_type']=='Doctor':
q="select * from health where login_id='%s'"%(session['login_id'])
res1=select(q)
if res1:
session['health_id']=res1[0]['health_id']
return redirect(url_for('doctor.doctor_home'))
if res[0]['user_type']=='admin':
return redirect(url_for('admin.adminhome'))
return render_template('login.html')
@public.route('/phc_reg', methods=['get','post'])
def phc_reg():
if 'phc_reg' in request.form:
phc_name=request.form['phc_name']
place=request.form['place']
email=request.form['email']
phone=request.form['phone']
pincode=request.form['pincode']
uname=request.form['uname']
pwd=request.form['pwd']
# c_pwd=request.form['c_pwd']
ql="insert into login values(null,'%s','%s','pending')"%(uname,pwd)
res=insert(ql)
q="insert into phc values(null,'%s','%s','%s','%s','%s','%s','%s','%s')"%(res,phc_name,place,email,phone,pincode,uname,pwd)
insert(q)
flash("Register successfully")
return redirect(url_for('public.login'))
return render_template('phc_reg.html')