-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
121 lines (99 loc) · 3.77 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
#flask app
from flask import *
from flask_cors import CORS
from dedupe import *
from dedupe_bulk import *
import os
from werkzeug.utils import secure_filename
from werkzeug.datastructures import FileStorage
app = Flask(__name__)
CORS(app)
app.secret_key = 'sessionNameEZPZ'
@app.route('/')
def home():
return render_template('index.html')
@app.route('/mode')
def mode():
return render_template('mode.html')
@app.route('/singleMode')
def singleMode():
return render_template('singleMode.html')
@app.route('/multiMode')
def multiMode():
return render_template('multiMode.html')
@app.route('/dataUpload')
def dataUpload():
return render_template('dataUpload.html')
@app.route('/singleUserResult')
def singleUserResult():
return render_template('singleUserResult.html', data=session['temp_dict'])
@app.route('/failure')
def failure():
return render_template('failure.html')
@app.route('/check_duplication', methods=['POST'])
def check_duplication():
# Fetching the data from the form
MRN=request.form['MRN']
firstName=request.form['firstName']
lastName=request.form['lastName']
DOB=request.form['DOB']
State= request.form['State']
Pincode=request.form['Pincode']
Phone = request.form['Phone']
YOE=request.form['YOE']
Specialization= request.form['Specialization']
Education = request.form['Education']
# Fetching the scale values
MRNscale = request.form['MRNscale']
fNamescale = request.form['fNamescale']
lNamescale = request.form['lNamescale']
DOBscale = request.form['DOBscale']
Statescale = request.form['Statescale']
Pincodescale = request.form['Pincodescale']
Phonescale = request.form['Phonescale']
YOEscale = request.form['YOEscale']
Specializationscale = request.form['Specializationscale']
Educationscale = request.form['Educationscale']
response=checkDuplicates(MRN,firstName,lastName,DOB,State,Pincode,Phone,YOE,Specialization,
Education,MRNscale,fNamescale,lNamescale,DOBscale,Statescale,
Pincodescale,Phonescale,YOEscale,Specializationscale,Educationscale)
# response = {'fName': firstName, 'lName': lastName, 'YOE': YOE}
# print(response['check'])
# if response['check']==1:
# return redirect(url_for('singleUserResult'))
# # return render_template('singleUserResult.html')
# else:
session['temp_dict'] = response['data']
return jsonify(response), 200
@app.route('/uploader', methods = ['GET', 'POST'])
def upload_file():
if request.method == 'POST':
f = request.files['file']
f.save(secure_filename(f.filename))
session['filename'] = f.filename
return session['filename']
@app.route('/check_bulk_duplication', methods=['POST'])
def check_bulk_duplication():
MRNscale = request.form['MRNscale']
fNamescale = request.form['fNamescale']
lNamescale = request.form['lNamescale']
DOBscale = request.form['DOBscale']
Statescale = request.form['Statescale']
Pincodescale = request.form['Pincodescale']
Phonescale = request.form['Phonescale']
YOEscale = request.form['YOEscale']
Specializationscale = request.form['Specializationscale']
Educationscale = request.form['Educationscale']
filename= session['filename']
# Get the response
response=dedupe_bulk(filename,MRNscale,fNamescale,lNamescale,DOBscale,Statescale,
Pincodescale,Phonescale,YOEscale,Specializationscale,Educationscale)
return jsonify(response), 200
if __name__ == '__main__':
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument('-p', '--port', default=5000,
type=int, help="port to listen to")
args = parser.parse_args()
port = args.port
app.run(host='127.0.0.1', port=port, debug=True)