forked from prashastigupta2004/Job_Counselor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.py
55 lines (39 loc) · 1.67 KB
/
application.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
from flask import Flask, render_template, request, redirect, url_for
import os
import uuid
import pandas as pd
from src.resume_parser import extract_text_from_pdf, extract_skills # Import the necessary functions
from src.utils import match_skills_with_jobs
app = Flask(__name__)
UPLOAD_FOLDER = 'uploads'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
# Load job postings dataset
job_postings_dataset_path = "notebooks/data/final_datasets.csv"
job_postings_data = pd.read_csv(job_postings_dataset_path)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/upload', methods=['POST'])
def upload_file():
if 'resume' not in request.files:
return redirect(request.url)
resume = request.files['resume']
if resume.filename == '':
return redirect(request.url)
if resume:
# Save the uploaded resume
filename = str(uuid.uuid4()) + '.pdf'
resume.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
# Extract skills from the uploaded resume
resume_text = extract_text_from_pdf(os.path.join(app.config['UPLOAD_FOLDER'], filename))
extracted_skills = extract_skills(resume_text)
# Match skills with job postings and get matching URLs
matching_urls = match_skills_with_jobs(extracted_skills, job_postings_data)
# Pass the matching URLs to the home template
return redirect(url_for('home', matching_urls=matching_urls))
@app.route('/home')
def home():
matching_urls = request.args.getlist('matching_urls')
return render_template('home.html', matching_urls=matching_urls)
if __name__ == '__main__':
app.run(debug=True) # Turn off debug mode