Spaces:
Sleeping
Sleeping
Db Connection added
Browse files- README.md +2 -0
- UploadFile.py +27 -0
- app.py +15 -2
README.md
CHANGED
@@ -9,3 +9,5 @@ license: apache-2.0
|
|
9 |
---
|
10 |
|
11 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
9 |
---
|
10 |
|
11 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
12 |
+
|
13 |
+
https://vaibhav84-resumeapi.hf.space/docs
|
UploadFile.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datetime import date
|
2 |
+
import psycopg2
|
3 |
+
from psycopg2 import sql
|
4 |
+
import pandas as pd
|
5 |
+
|
6 |
+
class UploadOpenFile:
|
7 |
+
|
8 |
+
def uploadFile(text,filePath,db_params):
|
9 |
+
|
10 |
+
conn = psycopg2.connect(**db_params)
|
11 |
+
cursor = conn.cursor()
|
12 |
+
query = "Select max(jdmasterid) from JdMaster"
|
13 |
+
df = pd.read_sql_query(query, conn)
|
14 |
+
try:
|
15 |
+
MasterId = df.iat[0,0] + 1
|
16 |
+
except:
|
17 |
+
MasterId =1
|
18 |
+
|
19 |
+
#print(MasterId)
|
20 |
+
query =sql.SQL("""INSERT INTO JDMaster (jdmasterid,jobdescription, filename, UploadedDate, IsDetailsExtracted,IsSkillsExtracted,source) VALUES (%s,%s,%s,%s,%s,%s,%s)""")
|
21 |
+
cursor.execute(query, (MasterId,text,filePath, date.today(),0,0,"JD"))
|
22 |
+
conn.commit()
|
23 |
+
cursor.close()
|
24 |
+
conn.close()
|
25 |
+
print("File Uploaded...")
|
26 |
+
return "File Uploaded Successfully!!!"
|
27 |
+
|
app.py
CHANGED
@@ -4,11 +4,20 @@ import json
|
|
4 |
from psycopg2 import sql
|
5 |
import pandas as pd
|
6 |
from DbConnection import DbConnection
|
|
|
|
|
7 |
app = FastAPI()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
@app.get("/")
|
9 |
async def root():
|
10 |
return {"greeting":"Hello world"}
|
11 |
-
|
12 |
db_params = DbConnection.GetDbConnection()
|
13 |
def parse_csv(df):
|
14 |
res = df.to_json(orient="records")
|
@@ -20,4 +29,8 @@ def ProfileMatchResults():
|
|
20 |
dbQuery = "select * from profilematch"
|
21 |
conn = psycopg2.connect(**db_params)
|
22 |
df = pd.read_sql_query(dbQuery, conn)
|
23 |
-
return parse_csv(df)
|
|
|
|
|
|
|
|
|
|
4 |
from psycopg2 import sql
|
5 |
import pandas as pd
|
6 |
from DbConnection import DbConnection
|
7 |
+
from UploadFile import UploadOpenFile
|
8 |
+
from pydantic import BaseModel
|
9 |
app = FastAPI()
|
10 |
+
|
11 |
+
class FileDetails(BaseModel):
|
12 |
+
filecontents: str
|
13 |
+
filename: str
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
@app.get("/")
|
18 |
async def root():
|
19 |
return {"greeting":"Hello world"}
|
20 |
+
#https://vaibhav84-resumeapi.hf.space/docs
|
21 |
db_params = DbConnection.GetDbConnection()
|
22 |
def parse_csv(df):
|
23 |
res = df.to_json(orient="records")
|
|
|
29 |
dbQuery = "select * from profilematch"
|
30 |
conn = psycopg2.connect(**db_params)
|
31 |
df = pd.read_sql_query(dbQuery, conn)
|
32 |
+
return parse_csv(df)
|
33 |
+
|
34 |
+
@app.post("/UploadFile/")
|
35 |
+
def UploadFileDetails(file_data: FileDetails):
|
36 |
+
return UploadOpenFile.uploadFile(file_data.filecontents,file_data.filename,db_params)
|