-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
51 lines (36 loc) · 1.49 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
from flask import Flask, redirect, render_template, jsonify, request, session
from flask_session import Session
import pandas as pd
from utils import *
app = Flask(__name__)
app.config["SESSION_PERMANENT"] = False
app.config["SESSION_TYPE"] = "filesystem"
app.config["SECRET_KEY"] = "dev"
Session()
@app.route("/", methods = ["GET", "POST"])
def index():
return redirect("/process_resume")
@app.route("/process_resume", methods = ["GET", "POST"])
def process():
if(request.method == "POST"):
#if uid not in session_var, create and store
if("uid" not in session):
session["uid"] = str(uuid.uuid4())
conn = sqlite3.connect("resume_db")
cursor = conn.cursor()
cursor.execute(
"CREATE TABLE IF NOT EXISTS resume_data (uid TEXT, name TEXT, email TEXT, contact TEXT, skills TEXT, experience TEXT)"
)
conn.commit()
pdf = request.files['resume_file']
text = get_pdf_text(pdf)
response = query_response(text)
response_dict = json.loads(response)
save_to_db(conn, cursor, session["uid"], response_dict)
db_res = fetch_from_db(conn, cursor, session["uid"])
db_res = convert(db_res) #since jinja2 is best suited for dicts, convert from (list of tuples) to (list of dicts)
return render_template("upload_resume.html", res = db_res)
else:
return render_template("upload_resume.html", res = "")
if(__name__ == "__main__"):
app.run(debug = True)