-
Notifications
You must be signed in to change notification settings - Fork 203
/
app.py
166 lines (112 loc) · 4.21 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
"""
Created on March 2018
@author:
▒█▀▀█ █▀▀█ █▀▀▄ █▀▀ ▒█▀▀█ █░░█ ▀▀█▀▀ █▀▀
▒█░░░ █░░█ █░░█ █▀▀ ▒█▀▀▄ █▄▄█ ░░█░░ █▀▀
▒█▄▄█ ▀▀▀▀ ▀▀▀░ ▀▀▀ ▒█▄▄█ ▄▄▄█ ░░▀░░ ▀▀▀
"""
#################################################################################################################################################
"""
● A web app to help employers by analysing resumes and CVs, surfacing candidates that best match the position and filtering out those who don't.
● Used recommendation engine techniques such as KNN, content based filtering for fuzzy matching job description with multiple resumes.
Prerequisites
Gensim
Numpy==1.11.3
Pandas
Sklearn
Dash
Antiwords
autocorrect
To Run this code:
# python app.py
And open URL localhost:5000
"""
import glob
import os
import warnings
import textract
import requests
from flask import (Flask,session, g, json, Blueprint,flash, jsonify, redirect, render_template, request,
url_for, send_from_directory)
from gensim.summarization import summarize
from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer
from sklearn.neighbors import NearestNeighbors
from werkzeug import secure_filename
import pdf2txt as pdf
import PyPDF2
import screen
import search
import hashlib
warnings.filterwarnings(action='ignore', category=UserWarning, module='gensim')
app = Flask(__name__)
app.config.from_object(__name__) # load config from this file , flaskr.py
# Load default config and override config from an environment variable
app.config.update(dict(
USERNAME='admin',
PASSWORD='7b4d7a208a333b46acdc9da159e5be7a',
SECRET_KEY='development key',
))
app.config['UPLOAD_FOLDER'] = 'Original_Resumes/'
app.config['ALLOWED_EXTENSIONS'] = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
class jd:
def __init__(self, name):
self.name = name
def getfilepath(loc):
temp = str(loc).split('\\')
return temp[-1]
@app.route('/login', methods=['GET', 'POST'])
def login():
error = None
if request.method == 'POST':
if request.form['username'] != app.config['USERNAME']:
error = 'Invalid username'
elif app.config['PASSWORD'] != hashlib.md5(request.form['password'].encode('utf-8')).hexdigest():
error = 'Invalid password'
else:
session['logged_in'] = True
flash('You were logged in')
return redirect(url_for('home'))
return render_template('login.html', error=error)
@app.route('/logout')
def logout():
session.pop('logged_in', None)
flash('You were logged out')
return redirect(url_for('home'))
@app.route('/')
def home():
x = []
for file in glob.glob("./Job_Description/*.txt"):
res = jd(file)
x.append(jd(getfilepath(file)))
print(x)
return render_template('index.html', results = x)
@app.route('/results', methods=['GET', 'POST'])
def res():
if request.method == 'POST':
jobfile = request.form['des']
print(jobfile)
flask_return = screen.res(jobfile)
print(flask_return)
return render_template('result.html', results = flask_return)
@app.route('/resultscreen' , methods = ['POST', 'GET'])
def resultscreen():
if request.method == 'POST':
jobfile = request.form.get('Name')
print(jobfile)
flask_return = screen.res(jobfile)
return render_template('result.html', results = flask_return)
@app.route('/resultsearch' ,methods = ['POST', 'GET'])
def resultsearch():
if request.method == 'POST':
search_st = request.form.get('Name')
print(search_st)
result = search.res(search_st)
# return result
return render_template('result.html', results = result)
@app.route('/Original_Resume/<path:filename>')
def custom_static(filename):
return send_from_directory('./Original_Resumes', filename)
if __name__ == '__main__':
# app.run(debug = True)
# app.run('127.0.0.1' , 5000 , debug=True)
app.run('0.0.0.0' , 5000 , debug=True , threaded=True)