-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
679 lines (568 loc) · 24.1 KB
/
app.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
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
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.exc import IntegrityError
from flask import Flask, render_template, request, redirect, url_for, session, flash, send_file
from flask_mail import Mail, Message
import random
import string
from werkzeug.utils import secure_filename
import os
import plotly.express as px
import numpy as np
# from tensorflow.keras.preprocessing import image
# import tensorflow as tf
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
import numpy as np,pandas as pd
import os
import csv
from dotenv import load_dotenv
# import pdfkit
from reportlab.pdfgen import canvas
from io import BytesIO
from flask.helpers import send_file
from reportlab.lib.pagesizes import letter
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.platypus import SimpleDocTemplate, Paragraph, Image, Spacer
from io import BytesIO
app = Flask(__name__)
mail = Mail(app)
load_dotenv()
app.secret_key = 'MYSECRETKEY'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['MAIL_SERVER'] = os.getenv('MAIL_SERVER')
app.config['MAIL_PORT'] = int(os.getenv('MAIL_PORT') or 465)
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = os.getenv('MAIL_USERNAME')
app.config['MAIL_PASSWORD'] = os.getenv('MAIL_PASSWORD')
app.config['MAIL_DEFAULT_SENDER'] = os.getenv('MAIL_DEFAULT_SENDER')
mail = Mail(app)
db = SQLAlchemy(app)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True, nullable=False)
email = db.Column(db.String(120), nullable=False)
password = db.Column(db.String(120), nullable=False)
type_of_doctor = db.Column(db.String(50))
class Appointment(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), nullable=False)
age = db.Column(db.Integer, nullable=False)
blood_group = db.Column(db.String(10), nullable=False)
time_slot = db.Column(db.String(50), nullable=False)
phone_number = db.Column(db.String(15), nullable=False)
email = db.Column(db.String(120), nullable=False)
type_of_doctor = db.Column(db.String(50))
status = db.Column(db.String(20), default='Pending')
prescription_file = db.Column(db.String(255))
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
user = db.relationship('User', backref=db.backref('appointments', lazy=True))
def create_tables():
with app.app_context():
db.create_all()
def generate_random_string(length=10):
letters_and_digits = string.ascii_letters + string.digits
return ''.join(random.choice(letters_and_digits) for i in range(length))
def send_mail(subject, recipient, body):
msg = Message(subject, recipients=[recipient])
msg.body = body
mail.send(msg)
# Set the path to the directory containing text files
text_files_dir = os.path.join(os.path.dirname(__file__), 'static/prescriptions')
# Set the path to the directory where PDFs will be saved
pdf_output_dir = os.path.join(os.path.dirname(__file__), 'static/pdfs')
# Function to convert text file to PDF
def convert_to_pdf(file_path, output_path):
with open(file_path, 'r') as file:
content = file.read()
pdfkit.from_string(content, output_path, {'title': 'PDF Conversion', 'footer-center': '[page]/[topage]'})
# ============================================================ model ============================================================
data = pd.read_csv(os.path.join("static","Data", "Training.csv"))
df = pd.DataFrame(data)
cols = df.columns
cols = cols[:-1]
x = df[cols]
y = df['prognosis']
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.33, random_state=42)
dt = DecisionTreeClassifier()
clf_dt=dt.fit(x_train,y_train)
indices = [i for i in range(132)]
symptoms = df.columns.values[:-1]
dictionary = dict(zip(symptoms,indices))
def predict(symptom):
user_input_symptoms = symptom
user_input_label = [0 for i in range(132)]
for i in user_input_symptoms:
idx = dictionary[i]
user_input_label[idx] = 1
user_input_label = np.array(user_input_label)
user_input_label = user_input_label.reshape((-1, 1)).transpose()
predicted_disease = dt.predict(user_input_label)[0]
confidence_score = np.max(dt.predict_proba(user_input_label)) * 100 # Assuming decision tree has predict_proba method
return predicted_disease, confidence_score
with open('static/Data/Testing.csv', newline='') as f:
reader = csv.reader(f)
symptoms = next(reader)
symptoms = symptoms[:len(symptoms)-1]
# ============================================================ routes ============================================================
@app.route('/', methods=['GET', 'POST'])
def index():
username = None
if 'user_id' in session:
user = User.query.get(session['user_id'])
username = user.username
if user.type_of_doctor:
appointments = Appointment.query.filter_by(type_of_doctor=user.type_of_doctor).all()
return render_template('doctor-dashboard.html', username=username, appointments=appointments)
else:
user_appointments = user.appointments
return render_template('patient-dashboard.html', username=username, user_appointments=user_appointments)
return render_template('index.html')
@app.route('/profile', methods=['GET', 'POST'])
def profile():
username = None
if 'user_id' in session:
user = User.query.get(session['user_id'])
username = user.username
Email = user.email
user_appointments = user.appointments
return render_template('patient-profile.html', username=username,Email=Email, user_appointments=user_appointments)
return render_template('index')
@app.route('/patient-register', methods=['GET', 'POST'])
def register():
if request.method == 'POST':
username = request.form['username']
email = request.form['email']
password = request.form['password']
try:
user = User(username=username, email=email, password=password)
db.session.add(user)
db.session.commit()
session['user_id'] = user.id
return redirect(url_for('index'))
except IntegrityError:
db.session.rollback()
flash('Username already exists. Please choose a different username.', 'error')
return render_template('patient-register.html')
@app.route('/doctor-register', methods=['GET', 'POST'])
def doctor_register():
if request.method == 'POST':
username = request.form['username']
email = request.form['email']
password = request.form['password']
type_of_doctor = request.form['type_of_doctor']
user = User(username=username,email=email, password=password, type_of_doctor=type_of_doctor)
db.session.add(user)
db.session.commit()
session['user_id'] = user.id
return redirect(url_for('index'))
return render_template('doctor-register.html')
@app.route('/login', methods=['GET', 'POST'])
def login():
if request.method == 'POST':
username = request.form['username']
password = request.form['password']
user = User.query.filter_by(username=username, password=password).first()
if user:
session['user_id'] = user.id
return redirect(url_for('index'))
else:
flash('Wrong username or password. Please try again.', 'error')
return render_template('login.html')
@app.route('/logout')
def logout():
session.pop('user_id', None)
return redirect(url_for('index'))
@app.route('/book-appointment', methods=['GET', 'POST'])
def book_appointment():
if 'user_id' not in session:
return redirect(url_for('login'))
username = None
user = User.query.get(session['user_id'])
username = user.username
# Fetch distinct types of doctors from the database
doctor_types = db.session.query(User.type_of_doctor).distinct().all()
doctor_types = [doctor[0] for doctor in doctor_types]
if request.method == 'POST':
name = request.form['name']
age = int(request.form['age'])
blood_group = request.form['blood_group']
time_slot = request.form['time_slot']
phone_number = request.form['phone_number']
email = request.form['email']
type_of_doctor = request.form['type_of_doctor']
appointment = Appointment(
name=name,
age=age,
blood_group=blood_group,
time_slot=time_slot,
phone_number=phone_number,
email=email,
type_of_doctor=type_of_doctor,
user=user
)
db.session.add(appointment)
db.session.commit()
# Notify the doctor via email
doctor_email = User.query.filter_by(type_of_doctor=type_of_doctor).first().email
subject = 'New Appointment Request'
body = f'Hello Doctor,\n\nYou have a new appointment request. Please log in to the system to approve or reject it.'
send_mail(subject, doctor_email, body)
return redirect(url_for('index'))
return render_template('book-appointment.html',doctor_types=doctor_types,username=username)
@app.route('/approve-appointment/<int:appointment_id>')
def approve_appointment(appointment_id):
if 'user_id' not in session:
return redirect(url_for('login'))
doctor = User.query.get(session['user_id'])
appointment = Appointment.query.get(appointment_id)
if appointment.type_of_doctor != doctor.type_of_doctor:
return redirect(url_for('index'))
appointment.status = 'Approved'
db.session.commit()
# Notify the patient via email
subject = 'Appointment Approved'
body = f'Hello {appointment.name},\n\nYour appointment has been approved. Please log in to the system to view the details.'
send_mail(subject, appointment.email, body)
return redirect(url_for('index'))
@app.route('/policy')
def policy():
return render_template('privacy-policy.html')
@app.route('/Transforming_Healthcare')
def Transforming_Healthcare():
username = None
if 'user_id' in session:
user = User.query.get(session['user_id'])
username = user.username
return render_template('blog_Transforming Healthcare.html',username=username)
return render_template('index.html')
@app.route('/Holistic_Health')
def Holistic_Health():
username = None
if 'user_id' in session:
user = User.query.get(session['user_id'])
username = user.username
return render_template('blog_Holistic Health.html',username=username)
return render_template('index.html')
@app.route('/Nourishing_Body')
def Nourishing_Body():
username = None
if 'user_id' in session:
user = User.query.get(session['user_id'])
username = user.username
return render_template('blog_Nourishing_Body.html',username=username)
return render_template('index.html')
@app.route('/Importance_of_Games')
def Importance_of_Games():
username = None
if 'user_id' in session:
user = User.query.get(session['user_id'])
username = user.username
return render_template('blog_Importance_of_Games.html',username=username)
return render_template('index.html')
@app.route('/admin')
def admin():
username = None
if 'user_id' in session:
user = User.query.get(session['user_id'])
username = user.username
return render_template('admin.html',username=username)
return render_template('index.html')
@app.route('/videocall')
def videocall():
if 'user_id' in session:
user = User.query.get(session['user_id'])
username = user.username
return render_template('videocall.html',username=username)
return render_template('index.html')
@app.route('/doctor-patients')
def doctor_patients():
username = None
if 'user_id' in session:
user = User.query.get(session['user_id'])
username = user.username
doctor = User.query.get(session['user_id'])
if not doctor.type_of_doctor:
return redirect(url_for('index'))
# Fetch appointments assigned to the doctor
appointments = Appointment.query.filter_by(type_of_doctor=doctor.type_of_doctor).all()
file_list = os.listdir(text_files_dir)
return render_template('doctor-patients.html', doctor=doctor, appointments=appointments,username=username,file_list=file_list)
return render_template('index.html')
@app.route('/prescribe-medicine/<int:appointment_id>', methods=['GET', 'POST'])
def prescribe_medicine(appointment_id):
if 'user_id' not in session:
return redirect(url_for('login'))
doctor = User.query.get(session['user_id'])
appointment = Appointment.query.get(appointment_id)
if appointment.type_of_doctor != doctor.type_of_doctor:
return redirect(url_for('index'))
# available_medicines = ["Medicine 1", "Medicine 2", "Medicine 3"] # Update this with your list of medicines
available_medicines = [
"Metformin: Diabetes",
"Levothyroxine: Hypothyroidism",
"Lisinopril: High Blood Pressure",
"Atorvastatin: High Cholesterol",
"Amlodipine: High Blood Pressure",
"Omeprazole: Acid Reflux",
"Metoprolol: High Blood Pressure",
"Albuterol: Asthma",
"Gabapentin: Nerve Pain",
"Losartan: High Blood Pressure",
"Fluticasone: Asthma",
"Sertraline: Depression",
"Hydrocodone/acetaminophen: Pain",
"Montelukast: Asthma",
"Bupropion: Depression",
"Escitalopram: Depression",
"Prednisone: Inflammation",
"Ventolin HFA: Asthma",
"Proair HFA: Asthma",
"Advair Diskus: Asthma",
"Latanoprost: Glaucoma",
"Duloxetine: Depression",
"Trazodone: Depression",
"Azithromycin: Antibiotic",
"Citalopram: Depression",
"Amlodipine/atorvastatin: Blood Pressure/Cholesterol",
"Warfarin: Blood Clots",
"SPIRIVA: COPD",
"Lyrica: Nerve Pain",
"Advair HFA: Asthma",
"Januvia: Diabetes",
"Vyvanse: ADHD",
"Nasonex: Allergies",
"Pantoprazole: Acid Reflux",
"Synthroid: Hypothyroidism",
"Zoloft: Depression",
"Celebrex: Arthritis",
"Xanax: Anxiety",
"Furosemide: Fluid Retention",
"Prozac: Depression",
"Simvastatin: High Cholesterol",
"Spiriva Respimat: COPD",
"Lexapro: Depression",
"Lantus: Diabetes",
"Viagra: Erectile Dysfunction",
"Singulair: Asthma",
"Crestor: High Cholesterol",
"Amoxicillin: Antibiotic",
"Cymbalta: Depression",
"Flovent HFA: Asthma",
"Victoza: Diabetes",
"Tamsulosin: Enlarged Prostate",
"Buspirone: Anxiety",
"Allopurinol: Gout",
"Lovastatin: High Cholesterol",
"Ibuprofen: Pain/Inflammation",
"Hydrochlorothiazide: High Blood Pressure",
"Ventolin: Asthma",
"Cephalexin: Antibiotic",
"Meloxicam: Arthritis",
"Clonazepam: Seizures/Anxiety",
"Lipitor: High Cholesterol",
"Nexium: Acid Reflux",
"Premarin: Menopause",
"Plavix: Blood Clots",
"Dulera: Asthma",
"Levemir: Diabetes",
"Amitriptyline: Depression",
"Humalog: Diabetes",
"Invokana: Diabetes",
"Symbicort: Asthma",
"Glimepiride: Diabetes",
"Flexeril: Muscle Spasms",
"Novolog: Diabetes",
"Bydureon: Diabetes",
"Breo Ellipta: Asthma",
"Janumet: Diabetes",
"Strattera: ADHD",
"NovoLog FlexPen: Diabetes",
"Trulicity: Diabetes Type 2",
"Benicar: High Blood Pressure",
"Actos: Diabetes",
"Pravastatin: High Cholesterol",
"Farxiga: Diabetes",
"Wellbutrin XL: Depression",
"Jardiance: Diabetes",
"Valacyclovir: Herpes",
"Femara: Breast Cancer",
"Ortho Tri-Cyclen: Birth Control",
"Lamotrigine: Seizures",
"Tramadol: Pain",
"Flomax: Enlarged Prostate",
"Prilosec OTC: Acid Reflux",
"Bystolic: High Blood Pressure",
"Aripiprazole: Schizophrenia",
"Combivent Respimat: COPD",
"Famotidine: Acid Reflux",
"Liraglutide: Diabetes",
"Carvedilol: High Blood Pressure",
"Oxcarbazepine: Seizures"]
if request.method == 'POST':
selected_medicines = request.form.getlist('medicines[]')
# Create a PDF document using ReportLab
buffer = BytesIO()
pdf = SimpleDocTemplate(buffer, pagesize=letter)
# Define styles for the header and footer
styles = getSampleStyleSheet()
header_style = ParagraphStyle(
'Header1',
parent=styles['Heading1'],
fontName='Helvetica-Bold',
fontSize=18,
spaceAfter=12,
textColor=colors.green,
)
footer_style = ParagraphStyle(
'Footer',
parent=styles['Normal'],
fontSize=10,
textColor=colors.gray,
)
content = []
# Add Jansevak header with green color and an <hr> tag
jansevak_header = Paragraph("<font color='green' size='24'><b>Jansevak: We Care for Your Health</b></font><hr/>", header_style)
content.append(jansevak_header)
# Add space after Jansevak header
content.append(Spacer(1, 12))
# Add patient details with a larger font size
patient_details = (
f"<font size='14'><b>Patient Details:</b></font><br/>"
f"<font size='12'>Name: {appointment.name}<br/>"
f"Age: {appointment.age}<br/>"
f"Blood Group: {appointment.blood_group}<br/>"
f"Phone Number: {appointment.phone_number}</font>"
)
content.append(Paragraph(patient_details, styles['Normal']))
# Add space after patient details
content.append(Spacer(1, 12))
# Add prescribed medicines with a larger font size
prescribed_meds = "<font size='14'><b>Prescribed Medicines:</b></font><br/>"
for medicine in selected_medicines:
prescribed_meds += f"<font size='12'>- {medicine}<br/></font>"
content.append(Paragraph(prescribed_meds, styles['Normal']))
# Add space after prescribed medicines
content.append(Spacer(1, 12))
# Add doctor details and footer with a larger font size
doctor_details = (
f"<font size='14'><b>Prescribed by Dr. {doctor.username} ({doctor.type_of_doctor})</b></font><br/>"
"<font size='12'>Thank you for choosing Jansevak! We wish you good health.</font>"
)
content.append(Paragraph(doctor_details, styles['Normal']))
# Add space after doctor details
content.append(Spacer(1, 12))
# Add computer-generated e-prescription footer
footer_text = (
"<font size='12'><i>This is a computer-generated e-prescription and does not require any signature.</i></font>"
)
content.append(Paragraph(footer_text, styles['Normal']))
# Build the PDF
pdf.build(content)
# Save the PDF to the file
pdf_filename = f"prescription_{appointment_id}.pdf"
pdf_filepath = os.path.join("static", "prescriptions", pdf_filename)
buffer.seek(0)
with open(pdf_filepath, 'wb') as pdf_file:
pdf_file.write(buffer.read())
buffer.close()
# Update appointment status to 'Prescribed'
appointment.status = 'Prescribed'
appointment.prescription_file = pdf_filepath
db.session.commit()
# Notify the patient via email
subject = 'Medicine Prescribed'
body = f'Hello {appointment.name},\n\nYour medicines has been Prescribed by your dcotor. Please log in to the system to view the and downlaod the e-presciption.\n\nThank you for choosing Jansevak! We wish you good health.'
send_mail(subject, appointment.email, body)
return redirect(url_for('doctor_patients'))
return render_template('prescribe-medicine.html', appointment=appointment, available_medicines=available_medicines)
@app.route('/view-prescription/<int:appointment_id>')
def view_prescription(appointment_id):
if 'user_id' not in session:
return redirect(url_for('login'))
doctor = User.query.get(session['user_id'])
appointment = Appointment.query.get(appointment_id)
if appointment.type_of_doctor != doctor.type_of_doctor or appointment.status != 'Prescribed':
return redirect(url_for('index'))
prescription_filepath = appointment.prescription_file
return send_file(prescription_filepath, as_attachment=True)
@app.route('/view-prescription-patient/<int:appointment_id>')
def view_prescription_patient(appointment_id):
if 'user_id' not in session:
return redirect(url_for('login'))
user = User.query.get(session['user_id'])
appointment = Appointment.query.get(appointment_id)
if not user or not appointment or appointment.user_id != user.id or appointment.status != 'Prescribed':
return redirect(url_for('profile')) # Change this line to redirect to the patient's profile instead of index
# Read prescription text from the file
prescription_filepath = appointment.prescription_file
return send_file(prescription_filepath, as_attachment=True)
@app.route('/mentalhealth', methods=['GET', 'POST'])
def mentalhealth():
username = None
if 'user_id' in session:
user = User.query.get(session['user_id'])
username = user.username
return render_template('mentalhealth.html',username=username)
else:
return render_template('index.html')
# ============================================================ scans ============================================================
@app.route('/braintumor', methods=['GET', 'POST'])
def braintumor():
username = None
if 'user_id' in session:
user = User.query.get(session['user_id'])
username = user.username
return render_template('brain-tumor.html',username=username)
else:
return render_template('index.html')
@app.route('/disease_predict', methods=['GET', 'POST'])
def disease_predict():
username = None
if 'user_id' in session:
user = User.query.get(session['user_id'])
username = user.username
chart_data={}
if request.method == 'POST':
selected_symptoms = []
if(request.form['Symptom1']!="") and (request.form['Symptom1'] not in selected_symptoms):
selected_symptoms.append(request.form['Symptom1'])
if(request.form['Symptom2']!="") and (request.form['Symptom2'] not in selected_symptoms):
selected_symptoms.append(request.form['Symptom2'])
if(request.form['Symptom3']!="") and (request.form['Symptom3'] not in selected_symptoms):
selected_symptoms.append(request.form['Symptom3'])
if(request.form['Symptom4']!="") and (request.form['Symptom4'] not in selected_symptoms):
selected_symptoms.append(request.form['Symptom4'])
if(request.form['Symptom5']!="") and (request.form['Symptom5'] not in selected_symptoms):
selected_symptoms.append(request.form['Symptom5'])
disease, confidence_score = predict(selected_symptoms)
chart_data = {
'disease': disease,
'confidence_score': confidence_score
}
return render_template('disease_predict.html',symptoms=symptoms,disease=disease, chart_data=chart_data,confidence_score=confidence_score,username=username)
return render_template('disease_predict.html',symptoms=symptoms,username=username,chart_data=chart_data)
else:
return render_template('index.html')
@app.route('/lung')
def lung():
username = None
if 'user_id' in session:
user = User.query.get(session['user_id'])
username = user.username
return render_template('lung.html',username=username)
else:
return render_template('index.html')
@app.route('/cataract')
def cataract():
username = None
if 'user_id' in session:
user = User.query.get(session['user_id'])
username = user.username
return render_template('cataract.html',username=username)
return render_template('index.html')
if __name__ == '__main__':
create_tables()
app.run(debug=True)