def patient_dash(): #usr=session['userno'] #Recieving the userid for db manipulation from the initilised session #sql="SELECT * FROM PROJECTS WHERE USERID = %s"%(usr) #projects=dbquery.fetchall(sql) if request.method=='POST': title = request.form['title'] remark = request.form['remark'] app.config['UPLOAD_FOLDER']="/Users/pranoy/Desktop/medi-fi/static/uploads/%s"%(session['email']) if not os.path.exists(app.config['UPLOAD_FOLDER']): os.makedirs(app.config['UPLOAD_FOLDER']) try: f = request.files['file'] f.save(os.path.join(app.config['UPLOAD_FOLDER'],f.filename)) print(f.filename) sql="INSERT INTO posts(email,title,remark,image,post_by) VALUES('%s','%s' ,'%s','%s','%s')"%(email,title,remark,f.filename,session['id']) dbquery.inserttodb(sql) except: sql="INSERT INTO posts(email,title,remark,post_by) VALUES('%s','%s' ,'%s','%s')"%(email,title,remark,session['id']) dbquery.inserttodb(sql) sql="SELECT * FROM patient WHERE email = '%s'"%(session['email']) datas = dbquery.fetchall(sql) sql="SELECT * FROM posts where email = '%s'"%(session['email']) posts = dbquery.fetchall(sql) return render_template('patient_dash.html',datas=datas,posts=posts)
def profile(email): #usr=session['userno'] #Recieving the userid for db manipulation from the initilised session #sql="SELECT * FROM PROJECTS WHERE USERID = %s"%(usr) #projects=dbquery.fetchall(sql) if request.method=='POST': title = request.form['title'] remark = request.form['remark'] app.config['UPLOAD_FOLDER']="/Users/pranoy/Desktop/medi-fi/static/uploads/%s"%(email) if not os.path.exists(app.config['UPLOAD_FOLDER']): os.makedirs(app.config['UPLOAD_FOLDER']) try: f = request.files['file'] f.save(os.path.join(app.config['UPLOAD_FOLDER'],f.filename)) sql="INSERT INTO posts(email,title,remark,image,post_by) VALUES('%s','%s' ,'%s','%s','%s')"%(email,title,remark,f.filename,session['id']) dbquery.inserttodb(sql) path = app.config['UPLOAD_FOLDER']+'/'+f.filename bashCommand = "python3 /Users/pranoy/Desktop/medi-fi/ml/predict.py %s"%(path) print(bashCommand) import subprocess process = subprocess.Popen(bashCommand.split(), stdout=subprocess.PIPE) except: sql="INSERT INTO posts(email,title,remark,post_by) VALUES('%s','%s' ,'%s','%s')"%(email,title,remark,session['id']) dbquery.inserttodb(sql) sql="SELECT * FROM patient WHERE email = '%s'"%(email) datas = dbquery.fetchall(sql) sql="SELECT * FROM posts where email = '%s'"%(email) posts = dbquery.fetchall(sql) return render_template('profile.html',datas=datas,posts=posts)
def projects(id): if id == session['userid']: return redirect(url_for('dashboard')) if request.method=='POST': message=request.form['message'] name =str(session['name']) message=name+": "+message sql="INSERT INTO CHATS(SENDER,RECIEVER,MESSAGE) VALUES('%d','%d','%s')"%(session['userid'],id,message) dbquery.inserttodb(sql) sql="SELECT MESSAGE FROM CHATS WHERE (SENDER = %d AND RECIEVER = %d) OR (SENDER= %d AND RECIEVER = %d) "%(session['userid'],id,id,session['userid']) chats=dbquery.fetchall(sql) return render_template("chat.html",chats=chats) try: sql="SELECT MESSAGE FROM CHATS WHERE (SENDER = %d AND RECIEVER = %d) OR (SENDER= %d AND RECIEVER = %d) "%(session['userid'],id,id,session['userid']) chats=dbquery.fetchall(sql) return render_template("chat.html",chats=chats) except: sql="INSERT INTO CHATS(SENDER,RECIEVER,MESSAGE) VALUES('%d','%d','%s')"%(session['userid'],id,"Say hello") dbquery.inserttodb(sql) sql="SELECT MESSAGE FROM CHATS WHERE (SENDER = %d AND RECIEVER = %d) OR (SENDER= %d AND RECIEVER = %d) "%(session['userid'],id,id,session['userid']) chats=dbquery.fetchall(sql) return render_template("chat.html",chats=chats)
def medibot(): if request.method == 'POST': try: slot = request.form['slot'] print(slot) medicine = request.form['medicine'] sql="INSERT INTO medibot(medicine,slot) VALUES('%s','%s' )"%(medicine,slot) dbquery.inserttodb(sql) #connecting to db model bashCommand = "curl -v -F slot=%s 192.168.43.112:80"%(slot) import subprocess process = subprocess.Popen(bashCommand.split(), stdout=subprocess.PIPE) except: dispense = request.form['dispense'] print(dispense) sql = "select * from medibot where medicine ='%s'"%(dispense) slotinfo = dbquery.fetchall(sql) slot = slotinfo[0][1] bashCommand = "curl -v -F slot=%s 192.168.43.112:80"%(slot) import subprocess process = subprocess.Popen(bashCommand.split(), stdout=subprocess.PIPE) sql ="delete from medibot where slot ='%s'"%(slot) dbquery.inserttodb(sql) sql = "select * from medicine" medicines = dbquery.fetchall(sql) sql = "select * from medibot" medicinebots = dbquery.fetchall(sql) return render_template('medibot.html',medicines = medicines, medicinebots = medicinebots)
def change(): if request.method == 'POST': location = request.form['location'] sql="UPDATE USERS SET CITY= '%s' WHERE USERID= %d "%(location,session['userid']) dbquery.inserttodb(sql) session['city']=location return redirect(url_for('dashboard')) return render_template('change.html')
def data_from_model(): if request.method == 'POST': x = request.get_json() time = x['time'] userid = x['userid'] sql = "INSERT INTO DATA VALUES (%s ,NOW(),%s);" % (userid, time) dbquery.inserttodb(sql) return "200" return "Error"
def medicine_data(): if request.method== 'POST': name = request.form['medicinename'] disease = request.form['disease'] cost = request.form['cost'] sql="INSERT INTO medicine(userid,medicine,disease,cost) VALUES('%s','%s' ,'%s','%s')"%(session['id'],name,disease,cost) dbquery.inserttodb(sql) #connecting to db model message="Medicine Added to Database" return render_template('medicine_data.html',message=message) return render_template('medicine_data.html')
def auth(): if request.method == 'POST': nurse = request.form['nurse'] patient = request.form['patient'] print(nurse,patient) sql = "INSERT INTO rfid(nurse,patient) VALUES('%s','%s')"%(nurse,patient) dbquery.inserttodb(sql) return "200" #usr=session['userno'] #Recieving the userid for db manipulation from the initilised session sql="SELECT * FROM rfid " info=dbquery.fetchall(sql) return render_template('nurse_dash.html',info=info)
def create(): if request.method=='POST': location= request.form['location'] cost = request.form['cost'] timing = request.form['timing'] contact = request.form['number'] address = request.form['address'] sql="INSERT INTO TOILETS(LOCATION,COST,TIMING,CONTACTNO,USERID,ADDRESS) VALUES('%s','%s' ,'%s','%s','%s','%s')"%(location,cost,timing,contact,session['userid'],address) dbquery.inserttodb(sql) #connecting to db model return redirect( url_for('dashboard')) #redirecting to login page return render_template('create.html')
def register_patient(): if request.method== 'POST': name = request.form['name'] age = request.form['age'] blood = request.form['bloodgroup'] weight = request.form['weight'] height = request.form['height'] email = request.form['email'] gender = request.form['gender'] phno = request.form['phno'] issue = request.form['issue'] sql="INSERT INTO patient(nurseid,name,age,blood,weight,height,email,phno,gender,issue) VALUES('%s','%s' ,'%s','%s','%s','%s' ,'%s','%s','%s','%s')"%(session['id'],name,age,blood,weight,height,email,phno,gender,issue) dbquery.inserttodb(sql) #connecting to db model message="Patient Registration Successful" return render_template('register_patient.html',message=message) return render_template('register_patient.html')
def signup(): if request.method == 'POST': email = request.form['email'] #GET FORM FIELDS password_candidate= request.form['password'] name = request.form['name'] sql="SELECT USERID FROM USERS WHERE EMAIL='%s'"%(email) #Security check on email try: rows = dbquery.fetchone(sql) #if none, error should be raised for row in rows: f=1 except: sql="INSERT INTO USERS(NAME,EMAIL,PASSWORD) VALUES('%s','%s' ,'%s')"%(name,email,password_candidate) dbquery.inserttodb(sql) #connecting to db model flash('You are now registered! Please Log in.','success') #sending a message to user return redirect(url_for('login')) #redirecting to login page flash('This Email exists!','success') #Checking for email return render_template('signup.html') return render_template('signup.html')
def signup(): if request.method == 'POST': message=None email = request.form['email'] #GET FORM FIELDS name = request.form['name'] password= request.form['password'] type = request.form['type'] sql="SELECT userno FROM users WHERE email='%s'"%(email) #Security check on username try: rows = dbquery.fetchone(sql) #if none, error should be raised for row in rows: f=1 except: sql="INSERT INTO users(name,email,password,type) VALUES('%s','%s' ,'%s','%s')"%(name,email,password,type) dbquery.inserttodb(sql) #connecting to db model message="User Registration Successful" return render_template('signup.html',message=message) message="Email Exists" return render_template('signup.html',message=message) return render_template('signup.html')
def signup(): if request.method== 'POST': #retrieving values from user if POST name = request.form['name'] email = request.form['email'] password= request.form['password'] country=request.form['country'] country=country.lower() city=request.form['city'] city=city.lower() sql="SELECT USERID FROM USERS WHERE EMAIL='%s'"%(email) #Security check on email try: rows = dbquery.fetchone(sql) #if none, error should be raised for row in rows: f=1 except: sql="INSERT INTO USERS(NAME,EMAIL,PASSWORD,COUNTRY,CITY) VALUES('%s','%s' ,'%s','%s','%s')"%(name,email,password,country,city) dbquery.inserttodb(sql) #connecting to db model flash('You are now registered! Please Log in.','success') #sending a message to user return redirect( url_for('login')) #redirecting to login page flash('This Email exists!','success') #Checking for email return render_template('signup.html') return render_template('signup.html') # rendering the signup page
def appointment(): if request.method== 'POST': patient = request.form['patient'] doctor = request.form['doctor'] date = request.form['date'] sql = "SELECT * from patient where name = '%s'"%(patient) data = dbquery.fetchall(sql) patientEmail = data[0][5] sql = "SELECT * from users where name = '%s' and type = 'Doctor'"%(doctor) data = dbquery.fetchall(sql) doctorEmail = data[0][2] sql = "SELECT * from users where userno = '%s' and type = 'Nurse'"%(session['id']) data = dbquery.fetchall(sql) nurse = data[0][1] sql="INSERT INTO appointment(userid,patient,doctor,date,patientEmail,doctorEmail,nurseemail,nurse) VALUES('%s','%s' ,'%s','%s','%s','%s','%s','%s')"%(session['id'],patient,doctor,date,patientEmail,doctorEmail,session['email'],nurse) dbquery.inserttodb(sql) #connecting to db model message="Appointment Created" return render_template('appointment.html',message=message) sql = "select name from patient where nurseid ='%s'"%(session['id']) patients=dbquery.fetchall(sql) sql = "select name from users where type ='Doctor'" doctors = dbquery.fetchall(sql) return render_template('appointment.html',patients=patients,doctors=doctors)
def get_features(model, image_path): img = image.load_img(image_path, target_size=image_size) x = image.img_to_array(img) x = np.expand_dims(x, axis=0) x = preprocess_input(x) feature = model.predict(x) flat = feature.flatten() return flat model = get_model() model.summary() classifier = pickle.load(open(classifier_file, 'rb')) # keep this much loaded always parser = argparse.ArgumentParser() parser.add_argument("Image_path") args = parser.parse_args() image_path = args.Image_path feature = get_features(model, image_path) result = classifier.predict(np.asarray(feature).reshape(1, -1)) le = pickle.load(open(labelencoder_file, 'rb')) res = le.inverse_transform(result) print(res[0]) string1 = image_path.split('/') path1 = string1[len(string1) - 1] sql = "update posts set tag='%s' where image='%s' " % (res[0], path1) dbquery.inserttodb(sql)