Nassiraaa commited on
Commit
a830d08
·
verified ·
1 Parent(s): 6cbd206

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -10
app.py CHANGED
@@ -1,31 +1,37 @@
1
  import streamlit as st
2
- import tempfile
3
  import os
4
  from cv_analyzer import analyze_cv
5
  from cv_quality import CV
 
6
 
7
  st.set_page_config(page_title="CV Analyzer", layout="wide")
8
  st.title('CV Analyzer')
9
 
 
 
 
10
  uploaded_file = st.file_uploader("Choose a CV file", type=['pdf', 'docx', 'txt'])
11
 
12
  if uploaded_file is not None:
13
- with st.spinner('Analyzing CV...'):
14
- # Create a temporary file
15
- with tempfile.NamedTemporaryFile(delete=False, suffix=os.path.splitext(uploaded_file.name)[1]) as tmp_file:
16
- tmp_file.write(uploaded_file.getvalue())
17
- tmp_file_path = tmp_file.name
 
 
18
 
19
- # Create CV object with the temporary file path
20
- cv = CV(tmp_file_path)
21
  result = cv.analyse_cv_quality()
22
 
23
- # Delete the temporary file
24
- os.unlink(tmp_file_path)
25
 
26
  if "error" in result:
27
  st.error(result["error"])
28
  else:
 
29
  # Personal Information
30
  st.header("Personal Information")
31
  personal_info = result["personal_info"]
 
1
  import streamlit as st
 
2
  import os
3
  from cv_analyzer import analyze_cv
4
  from cv_quality import CV
5
+ from get_supabase import Supabase
6
 
7
  st.set_page_config(page_title="CV Analyzer", layout="wide")
8
  st.title('CV Analyzer')
9
 
10
+ # Initialize Supabase client
11
+ supabase_client = Supabase().init_supabase_client()
12
+
13
  uploaded_file = st.file_uploader("Choose a CV file", type=['pdf', 'docx', 'txt'])
14
 
15
  if uploaded_file is not None:
16
+ with st.spinner('Uploading and analyzing CV...'):
17
+ # Upload file to Supabase storage
18
+ file_path = f"cvs/{uploaded_file.name}"
19
+ supabase_client.storage.from_("cvs").upload(file_path, uploaded_file.getvalue())
20
+
21
+ # Get the public URL of the uploaded file
22
+ file_url = supabase_client.storage.from_("cvs").get_public_url(file_path)
23
 
24
+ # Create CV object with the file URL
25
+ cv = CV(file_url)
26
  result = cv.analyse_cv_quality()
27
 
28
+ # Optionally, delete the file after analysis
29
+ # supabase_client.storage.from_("cvs").remove([file_path])
30
 
31
  if "error" in result:
32
  st.error(result["error"])
33
  else:
34
+ # Display results (same as before)
35
  # Personal Information
36
  st.header("Personal Information")
37
  personal_info = result["personal_info"]