From 994c18756416e15c8350520ecf456de81d289d47 Mon Sep 17 00:00:00 2001 From: Aditya Bhardwaj Date: Sat, 13 Oct 2018 10:59:49 +0000 Subject: [PATCH] Login Added --- app.py | 52 +++++++++++++++++++++++++++++++++++++++++++- static/css/style.css | 0 static/js/script.js | 0 templates/index.html | 0 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 static/css/style.css create mode 100644 static/js/script.js create mode 100644 templates/index.html diff --git a/app.py b/app.py index 544f840..624024e 100644 --- a/app.py +++ b/app.py @@ -7,6 +7,7 @@ import datetime import csv import diagnosisClient +from googlesearch import search from commons import json_response client = MongoClient() @@ -23,7 +24,6 @@ diagnosis = diagnosisClient.DiagnosisClient(username, password, authUrl, language, healthUrl) - @app.route('/') def index(): return '

Welcome to Medisyst!

' @@ -78,5 +78,55 @@ def generate(): rawHashString = hmac.new(bytes(x, encoding='utf-8'), x.encode('utf-8')).digest() computedHashString = base64.b64encode(rawHashString).decode() return computedHashString + +@app.route('/signup') +def signup(): + email=request.args.get('email') + password=request.args.get('password') + aadhaar = request.args.get('aadhaar') + gender = request.args.get('gender') + fname = request.args.get('fname') + lname =request.args.get('lname') + dob = request.args.get('dob') + A=[] + x=users.find({"email":email}) + for i in x: + A.append(x) + if(len(A)==0): + user={ + "email":email, + "password":password, + "aadhaar":aadhaar, + "gender":gender, + "fname":fname, + "lname":lname, + "dob":dob + } + x=users.insert_one(user) + print(x) + return "yes" + else: + return 'no' + +@app.route('/login') +def signin(): + email=request.args.get('email') + password=request.args.get('password') + A=[] + x=users.find_one({"email":email}) + print(x) + if(x['password']==password): + return "yes" + else: + return "no" + +@app.route('/search') +def gsearch(): + query = request.args.get('query') + A=[] + for j in search(query, num=10, stop=1): + A.append(j) + return json_response(A) + if __name__ == '__main__': app.run( host=os.environ['IP'], port=os.environ['PORT'] ,debug=True) \ No newline at end of file diff --git a/static/css/style.css b/static/css/style.css new file mode 100644 index 0000000..e69de29 diff --git a/static/js/script.js b/static/js/script.js new file mode 100644 index 0000000..e69de29 diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..e69de29