-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
752 lines (614 loc) · 25.5 KB
/
app.py
File metadata and controls
752 lines (614 loc) · 25.5 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
import os
import qrcode
from bson import ObjectId
from flask import Flask, render_template, redirect, session, flash, send_file, request, url_for
from flask_pymongo import PyMongo
from werkzeug.utils import secure_filename
from flask_bootstrap import Bootstrap
from databaseConnections import db_user, db_lab, db_qr
from forms import RegistrationFormUser, LoginFormUser, EditUserForm, RegistrationFormDoctor, LoginFormDoctor, \
SearchPatient, LoginFormLab, RegistrationFormLab, EntryFormPre, RegistrationFormMd, LoginFormMd, \
EntryFormPp
from model.models import Emergency, Address, User, Doctor, USER, Lab, Md
from query.DoctorQuery import create_doctor, find_doctor_by_id
from query.LabQuery import find_lab_by_id, create_lab
from query.MdQuery import create_md, find_user_by_Aadhar_M, find_md_by_id
from query.NewsQuery import find_latest_news
from query.PQuery import create_Pp
from query.UserQuery import create_user, find_user_by_id, get_user_aadhar, update_user, find_user_by_Aadhar, find_user
from flask_login import LoginManager, login_required, login_user, logout_user, current_user
from model.models import User, Qr
from query.preQuery import create_pre
import qrcode.image.svg
app = Flask(__name__)
Bootstrap(app)
app.config['MONGO_URI'] = 'mongodb+srv://SPUM:srinking69@myhealthcard-1nsmr.mongodb.net/Health?retryWrites=true&w=majority'
mongo = PyMongo(app)
app.config['SECRET_KEY'] = b'\xb0\xf4\xe8\\U\x8d\xba\xb4B2h\x88\xf9\x08\xb1J'
UPLOAD_FOLDER = '/home/utkarsh/HealthServer/UserData/'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
# client = MongoClient('localhost', 27017)
ALLOWED_EXTENSIONS = {'pdf'}
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'index'
AadharNo = None
currentLab = None
@app.route('/')
@app.route('/index')
def index():
return render_template('index.html')
@login_manager.user_loader
def load_user(user_id):
return USER(find_user(user_id))
@app.route('/newpatient', methods=["GET", "POST"])
def newpatient():
if session.get('username'):
return redirect('/index')
form = RegistrationFormUser()
if form.validate_on_submit():
Email = form.Email.data
Password = form.Password.data
AadharNo = form.AadharNo.data
Name = form.Name.data
ContactNo = form.ContactNo.data
Gender = form.Gender.data
DOB = form.DOB.data
Street1 = form.Street1.data
Street2 = form.Street2.data
City = form.City.data
State = form.State.data
Zip = form.Zip.data
EmergencyContactName = form.EmergencyContactName.data
EmergencyContactRelation = form.EmergencyContactRelation.data
EmergencyContactNumber = form.EmergencyContactNumber.data
user = create_user(Email=Email, Name=Name, AadharNo=AadharNo,
ContactNo=ContactNo, Gender=Gender, DOB=DOB,
Street1=Street1, Street2=Street2, City=City, State=State, Zip=Zip,
EmergencyContactName=EmergencyContactName, EmergencyContactRelation=EmergencyContactRelation,
EmergencyContactNumber=EmergencyContactNumber, Reports=0)
user.set_password(Password)
try:
user.save()
flash("New ID Created Successfully", "success")
return redirect("/login_patient")
except Exception as e:
flash("Failed to create user, try again")
print(e)
return redirect('/newpatient')
return render_template('newpatient.html', form=form)
@app.route('/login_patient', methods=["GET", "POST"])
def loginp():
if session.get('username') is not None:
Email = session.get('username')
user = User.objects(Email=Email).first()
name = user['Name']
name = "".join(name.split())
return redirect("/Patient/" + name.__str__())
form = LoginFormUser()
if form.validate_on_submit():
Email = form.Email.data
Password = form.Password.data
try:
user = User.objects(Email=Email).first()
if user and user.get_password(Password):
login_user(user, remember=True)
session['username'] = user.Email
name = user['Name']
name = "".join(name.split())
return redirect("/Patient/" + name.__str__())
else:
print("Incorrect username or password")
except Exception as e:
print(e)
return render_template('login_patient.html', form=form)
@app.route('/Patient/<name>', methods=["GET", "POST"])
@login_required
def patient(name):
return render_template('Patient.html')
@app.route('/Patient/Patient_home')
@login_required
def Patient_home():
return render_template('Patient_home.html')
def allowed_file(filename):
return '.' in filename and \
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
@app.route('/report_patient')
@login_required
def report_patient():
currentUser = session.get('username')
global AadharNo
aadhar = ""
if currentUser is not None:
aadhar = get_user_aadhar(currentUser)
elif AadharNo is not None:
aadhar = AadharNo
# return render_template('report_patient.html', files=files)
user = find_user_by_Aadhar(aadhar)
r = user["Reports"]
return render_template('report_patient.html', files=r)
@app.route('/return_files/<name>')
@login_required
def return_files_tut(name):
try:
currentUser = session.get('username')
global AadharNo
aadhar = ""
if currentUser is not None:
aadhar = get_user_aadhar(currentUser)
elif AadharNo is not None:
aadhar = AadharNo
user = find_user_by_Aadhar(aadhar)
filename = user['Rnames'][int(name)]
return mongo.send_file(filename)
#return send_file(path, attachment_filename=name)
except Exception as e:
return str(e)
@app.route('/info_patient')
@login_required
def info_patient():
currentUser = session.get('username')
patient = find_user_by_id(currentUser)
if patient is not None:
emergency_list = list(patient['EmergencyContact'].split(","))
return render_template('info_patient.html', Name=patient['Name'], Email=patient['Email'],
Aadhar=patient['AadharNo'], Gender=patient['Gender'], DOB=patient['DOB'],
Contact=patient['ContactNo'], Address=patient['Address'],
e_Name=emergency_list[0], e_Rel=emergency_list[1], e_Contact=emergency_list[2])
else:
return render_template('info_patient.html')
@app.route('/edit_info_patient', methods=['GET', 'POST'])
@login_required
def edit_info_patient():
currentUser = session.get('username')
user = find_user_by_id(currentUser)
address_list = list(user['Address'].split(','))
address = []
for i in address_list:
address.append(i.strip())
emergency_list = list(user['EmergencyContact'].split(','))
emergency = []
for i in emergency_list:
emergency.append(i.strip())
form = EditUserForm()
form.Name.data = user['Name']
form.Gender.data = user['Gender']
form.ContactNo.data = user['ContactNo']
form.DOB.data = user['DOB']
form.Street1.data = address[0]
form.Street2.data = address[1]
form.City.data = address[2]
form.State.data = address[3]
form.Zip.data = address[4]
form.EmergencyContactName.data = emergency[0]
form.EmergencyContactRelation.data = emergency[1]
form.EmergencyContactNumber.data = emergency[2]
if 'submit' in request.form:
Name = form.Name.data = request.form['Name']
ContactNo = form.ContactNo.data = request.form['ContactNo']
Gender = form.Gender.data = request.form['Gender']
DOB = form.DOB.data = request.form['DOB']
Street1 = form.Street1.data = request.form['Street1']
Street2 = form.Street2.data = request.form['Street2']
City = form.City.data = request.form['City']
State = form.State.data = request.form['State']
Zip = form.Zip.data = request.form['Zip']
EmergencyContactName = form.EmergencyContactName.data = request.form['EmergencyContactName']
EmergencyContactRelation = form.EmergencyContactRelation.data = request.form['EmergencyContactRelation']
EmergencyContactNumber = form.EmergencyContactNumber.data = request.form['EmergencyContactNumber']
if form.validate():
user = update_user(Email=currentUser, Name=Name, ContactNo=ContactNo, Gender=Gender, DOB=DOB,
Street1=Street1, Street2=Street2, City=City, State=State, Zip=Zip,
EmergencyContactName=EmergencyContactName,
EmergencyContactRelation=EmergencyContactRelation,
EmergencyContactNumber=EmergencyContactNumber)
return render_template('edit_info_patient.html', form=form, msg="Profile Updated Successfully")
return render_template('edit_info_patient.html', form=form, msg="")
@app.route('/currentnews')
def currentnews():
news = find_latest_news()
return render_template('currentnews.html', news=news)
@app.route('/news')
def news():
news = find_latest_news()
return render_template('Normal_news.html', news=news)
@app.route('/Trending')
@login_required
def Trending():
news = find_latest_news()
return render_template('user_cur_news.html', news=news)
@app.route('/newdoctor', methods=["GET", "POST"])
def newdoctor():
if session.get('doctorname'):
return redirect('/index')
form = RegistrationFormDoctor()
if form.validate_on_submit():
Email = form.Email.data
Password = form.Password.data
AadharNo = form.AadharNo.data
Name = form.Name.data
ContactNo = form.ContactNo.data
Gender = form.Gender.data
CertificateNo = form.CertificateNo.data
doctor = create_doctor(Email=Email, Name=Name, AadharNo=AadharNo,
ContactNo=ContactNo, Gender=Gender,
CertificateNo=CertificateNo)
doctor.set_password(Password)
try:
doctor.save()
flash("New ID Created Successfully", "success")
return redirect("/login_doc")
except Exception as e:
flash("Failed to create user, try again")
print(e)
return redirect('/newdoctor')
return render_template('newdoctor.html', form=form)
@app.route('/login_doc', methods=["GET", "POST"])
def logind():
if session.get('doctorname'):
Email = session.get('doctorname')
doctor = Doctor.objects(Email=Email).first()
name = doctor['Name']
name = "".join(name.split())
return redirect("/Doctor/" + name.__str__())
form = LoginFormDoctor()
if form.validate_on_submit():
Email = form.Email.data
Password = form.Password.data
doctor = Doctor.objects(Email=Email).first()
if doctor and doctor.get_password(Password):
login_user(doctor, remember=True)
session['doctorname'] = doctor.Email
name = doctor['Name']
name = "".join(name.split())
return redirect("/Doctor/" + name.__str__())
else:
flash("Incorrect username or password")
return render_template('login_doc.html', form=form)
@app.route('/Doctor/<name>', methods=["GET", "POST"])
@login_required
def doctor(name):
form = SearchPatient()
if form.validate_on_submit():
global AadharNo
AadharNo = form.AadharNo.data
return redirect('/doctor_w_patient')
return render_template('DOCTOR.html', form=form)
@app.route('/doctor_home')
@login_required
def doctor_home():
return render_template('doctor_home.html')
@app.route('/doctor_info')
@login_required
def doctor_info():
currentDoctor = session.get('doctorname')
doctor = find_doctor_by_id(currentDoctor)
if doctor is not None:
return render_template('doctor_info.html', Name=doctor['Name'], Email=doctor['Email'],
Aadhar=doctor['AadharNo'], Gender=doctor['Gender'],CertificateNo=doctor['CertificateNo'])
else:
return render_template('doctor_info.html')
@app.route('/doctor_w_patient')
@login_required
def doctor_w_patient():
return render_template('doctor_w_patient.html')
@app.route('/info_patient_by_doctor')
@login_required
def info_patient_by_doctor():
patient = find_user_by_Aadhar(AadharNo)
if patient is not None:
emergency_list = list(patient['EmergencyContact'].split(","))
return render_template('info_patient.html', Name=patient['Name'], Email=patient['Email'],
Aadhar=patient['AadharNo'], Gender=patient['Gender'], DOB=patient['DOB'],
Contact=patient['ContactNo'], Address=patient['Address'],
e_Name=emergency_list[0], e_Rel=emergency_list[1], e_Contact=emergency_list[2])
else:
return render_template('info_patient.html')
@app.route('/scan_qr', methods=['GET', 'POST'])
@login_required
def scan_qr():
email = session.get('labname')
labAadhar = db_lab.find_one({'Email': email})
if session.get('labname'):
email = session.get('labname')
labAadhar = db_lab.find_one({'Email': email})
qr = Qr()
qr.labAadhar = labAadhar['AadharNo']
qr.access = False
qr.userAadhar = ""
factory = qrcode.image.svg.SvgImage
img = qrcode.make(labAadhar['AadharNo'], image_factory=factory)
img.save('static/img/qr.svg')
try:
qr.save()
except Exception as e:
print(e)
print("asdasdasdas")
if request.method == 'POST':
return redirect('upload_report')
print("poosososo")
if "check" in request.form or 'check' in request.form:
print("asda")
lb = db_qr.find_one({"labAadhar": labAadhar["AadharNo"]})
access = lb["access"]
if access is True:
db_qr.delete_one({"labAadhar": labAadhar['AadharNo']})
return redirect('upload_report')
return render_template('display_qr.html')
@app.route('/upload_report', methods=['GET', 'POST'])
@login_required
def upload_report():
currentUser = session.get('username')
global AadharNo
aadhar = ""
if currentUser is not None:
aadhar = get_user_aadhar(currentUser)
elif AadharNo is not None:
aadhar = AadharNo
if request.method == 'POST':
if 'file' not in request.files:
flash('No file part')
return redirect(request.url)
file = request.files['file']
if file.filename == '':
flash('No selected file')
return redirect(request.url)
if file and allowed_file(file.filename):
file.filename = aadhar + "-" + file.filename
filename = secure_filename(file.filename)
mongo.save_file(filename, file)
user = find_user_by_Aadhar(aadhar)
reports = user["Reports"]
reports = reports + 1
user["Rnames"].append(file.filename)
db_user.update_one({"AadharNo": aadhar}, {"$set": {"Reports": reports, "Rnames": user['Rnames']}})
return render_template('upload_report.html')
return render_template('upload_report.html')
@app.route('/newlab', methods=["GET", "POST"])
def newlab():
if session.get('labname'):
return redirect('/index')
form = RegistrationFormLab()
if form.validate_on_submit():
Email = form.Email.data
Password = form.Password.data
AadharNo = form.AadharNo.data
Name = form.Name.data
ContactNo = form.ContactNo.data
lab = create_lab(Email=Email, Name=Name, AadharNo=AadharNo,
ContactNo=ContactNo)
lab.set_password(Password)
try:
lab.save()
flash("New ID Created Successfully", "success")
return redirect("/login_lab")
except Exception as e:
flash("Failed to create user, try again")
print(e)
return redirect('/newlab')
return render_template('newlab.html', form=form)
@app.route('/login_lab', methods=["GET", "POST"])
def loginlab():
if session.get('labname'):
Email = session.get('labname')
user = User.objects(Email=Email).first()
name = user['Name']
name = "".join(name.split())
return redirect("/Lab/" + name.__str__())
form = LoginFormLab()
if form.validate_on_submit():
Email = form.Email.data
Password = form.Password.data
try:
lab = Lab.objects(Email=Email).first()
print(lab)
if lab and lab.get_password(Password):
login_user(lab, remember=True)
print("asd")
session['labname'] = lab.Email
name = lab['Name']
print(name)
name = "".join(name.split())
return redirect("/Lab/" + name.__str__())
else:
print("Incorrect username or password")
except Exception as e:
print(e)
return render_template('login_lab.html', form=form)
@app.route('/Lab/<name>', methods=["GET", "POST"])
@login_required
def lab(name):
form = SearchPatient()
if form.validate_on_submit():
global AadharNo
AadharNo = form.AadharNo.data
return redirect('/lab_w_patient')
return render_template('Lab.html', form=form)
@app.route('/lab_info')
@login_required
def lab_info():
currentlab = session.get('labname')
lab = find_lab_by_id(currentlab)
if lab is not None:
return render_template('lab_info.html', Name=lab['Name'], Email=lab['Email'],
Aadhar=lab['AadharNo'])
else:
return render_template('lab_info.html')
@app.route('/lab_w_patient')
@login_required
def lab_w_patient():
return render_template('lab_w_patient.html')
@app.route('/info_patient_by_lab')
@login_required
def info_patient_by_lab():
global AadharNo
patient = find_user_by_Aadhar(AadharNo)
if patient is not None:
emergency_list = list(patient['EmergencyContact'].split(","))
return render_template('info_patient.html', Name=patient['Name'], Email=patient['Email'],
Aadhar=patient['AadharNo'], Gender=patient['Gender'], DOB=patient['DOB'],
Contact=patient['ContactNo'], Address=patient['Address'],
e_Name=emergency_list[0], e_Rel=emergency_list[1], e_Contact=emergency_list[2])
else:
return render_template('info_patient.html')
@app.route("/precautions", methods=["GET", "POST"])
def upload_pre():
global AadharNo
form = EntryFormPre()
if form.is_submitted():
P1 = form.P1.data
P2 = form.P2.data
P3 = form.P3.data
P4 = form.P4.data
P5 = form.P5.data
D1 = form.D1.data
D2 = form.D2.data
D3 = form.D3.data
D4 = form.D4.data
D5 = form.D5.data
T1 = form.T1.data
T2 = form.T2.data
T3 = form.T3.data
T4 = form.T4.data
T5 = form.T5.data
pre = create_pre(P1=P1, P2=P2, P3=P3, P4=P4, P5=P5, D1=D1, D2=D2, D3=D3, D4=D4, D5=D5, T1=T1, T2=T2, T3=T3,
T4=T4, T5=T5, preAadhar=AadharNo)
try:
pre.save()
flash("New ID Created Successfully", "success")
return render_template("upload_pre.html", form=form)
except Exception as e:
flash("Failed to create user, try again")
print(e)
return render_template('upload_pre.html', form=form)
return render_template('upload_pre.html', form=form)
@app.route('/newmd', methods=["GET", "POST"])
def newmd():
if session.get('mdname'):
return redirect('/index')
form = RegistrationFormMd()
if form.validate_on_submit():
Email = form.Email.data
Password = form.Password.data
AadharNo = form.AadharNo.data
Name = form.Name.data
ContactNo = form.ContactNo.data
md = create_md(Email=Email, Name=Name, AadharNo=AadharNo,
ContactNo=ContactNo)
md.set_password(Password)
try:
md.save()
flash("New ID Created Successfully", "success")
return redirect("/loginmd")
except Exception as e:
flash("Failed to create user, try again")
print(e)
return redirect('/newmedical')
return render_template('newmedical.html', form=form)
@app.route('/loginmd', methods=["GET", "POST"])
def loginmd():
if session.get('mdname'):
Email = session.get('mdname')
md = Md.objects(Email=Email).first()
name = md['Name']
name = "".join(name.split())
return redirect("/Medical")
form = LoginFormMd()
if form.validate_on_submit():
Email = form.Email.data
Password = form.Password.data
md = Md.objects(Email=Email).first()
if md and md.get_password(Password):
login_user(md, remember=True)
session['mdname'] = md.Email
name = md['Name']
name = "".join(name.split())
return redirect("/Medical")
else:
flash("Incorrect username or password")
return render_template('loginmd.html', form=form)
@app.route('/Medical', methods=["GET", "POST"])
def Medical():
form = SearchPatient()
if form.validate_on_submit():
global AadharNo
AadharNo = form.AadharNo.data
return redirect('md_w_patient')
return render_template('Medical.html', form=form)
@app.route('/md_info')
def md_info():
currentMd = session.get('mdname')
md = find_md_by_id(currentMd)
print(md)
if md is not None:
return render_template('md_info.html', Name=md['Name'], Email=md['Email'],
Aadhar=md['AadharNo'])
else:
return render_template('md_info.html')
@app.route('/md_w_patient')
def md_w_patient():
return render_template('md_w_patient.html')
@app.route('/view_pre')
def view_pre():
global AadharNo
patientM = find_user_by_Aadhar_M(AadharNo)
if patientM is not None:
return render_template('view_pre.html', P1=patientM['P1'], P2=patientM['P2'], P3=patientM['P3'],
P4=patientM['P4'], P5=patientM['P5'],
D1=patientM['D1'], D2=patientM['D2'], D3=patientM['D3'], D4=patientM['D4'],
D5=patientM['D5'],
T1=patientM['T1'], T2=patientM['T2'], T3=patientM['T3'], T4=patientM['T4'],
T5=patientM['T5'])
else:
return render_template('view_pre.html')
@app.route('/info_patient_by_md')
def info_patient_by_md():
global AadharNo
patient = find_user_by_Aadhar(AadharNo)
if patient is not None:
emergency_list = list(patient['EmergencyContact'].split(","))
return render_template('info_patient.html', Name=patient['Name'], Email=patient['Email'],
Aadhar=patient['AadharNo'], Gender=patient['Gender'], DOB=patient['DOB'],
Contact=patient['ContactNo'], Address=patient['Address'],
e_Name=emergency_list[0], e_Rel=emergency_list[1], e_Contact=emergency_list[2])
else:
return render_template('info_patient.html')
@app.route("/patientprofile", methods=["GET", "POST"])
def patientprofile():
form = EntryFormPp()
u = session.get('username')
aadhar = get_user_aadhar(u)
if form.validate_on_submit():
BloodGroup = form.BloodGroup.data
Age = form.Age.data
Alergies = form.Alergies.data
Weight = form.Weight.data
Height = form.Height.data
Habits = form.Habits.data
pp = create_Pp(AadharNo=aadhar, BloodGroup=BloodGroup, Age=Age, Alergies=Alergies, Weight=Weight, Height=Height, Habits=Habits)
try:
pp.save()
flash("New ID Created Successfully", "success")
return render_template("login_patient.html", form=form)
except Exception as e:
flash("Failed to create user, try again")
print(e)
return render_template('patientprofile.html', form=form)
return render_template('patientprofile.html', form=form)
@app.route("/logout")
@login_required
def logout():
if session.get('username') is not None:
session.pop('username')
if session.get('doctorname') is not None:
session.pop('doctorname')
if session.get('labname') is not None:
session.pop('labname')
if session.get('mdname') is not None:
session.pop('mdname')
logout_user()
return redirect("/index")
if __name__ == '__main__':
app.run(debug=True, host="127.0.0.1",
port=9000,
threaded=True)