Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -82,14 +82,30 @@ st.markdown("""
|
|
| 82 |
margin: 0 auto;
|
| 83 |
width: 150px;
|
| 84 |
}
|
|
|
|
| 85 |
.card {
|
| 86 |
background-color: #2d3748;
|
| 87 |
padding: 15px;
|
| 88 |
border-radius: 10px;
|
| 89 |
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
| 90 |
margin-bottom: 20px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
}
|
| 92 |
-
|
| 93 |
|
| 94 |
[data-testid="stSidebar"],
|
| 95 |
.st-emotion-cache-6qob1r {
|
|
@@ -570,103 +586,103 @@ if page == "CV Maker": # Assuming 'page' is defined elsewhere; use 'if' instead
|
|
| 570 |
print(f"Error details: {str(e)}")
|
| 571 |
return f"Error generating CV: {str(e)}"
|
| 572 |
|
| 573 |
-
def generate_cv_pdf(cv_content: str) -> BytesIO:
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
|
| 578 |
-
|
| 579 |
-
|
| 580 |
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
|
| 607 |
-
|
| 608 |
-
|
| 609 |
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
|
| 655 |
-
|
| 656 |
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
|
| 664 |
|
| 665 |
-
|
| 666 |
|
| 667 |
-
|
| 668 |
-
|
| 669 |
-
|
| 670 |
|
| 671 |
with st.form("cv_form"):
|
| 672 |
col1, col2 = st.columns(2)
|
|
@@ -698,13 +714,13 @@ if page == "CV Maker": # Assuming 'page' is defined elsewhere; use 'if' instead
|
|
| 698 |
file_name="John_Doe_CV.txt",
|
| 699 |
mime="text/plain"
|
| 700 |
)
|
| 701 |
-
pdf_buffer = generate_cv_pdf(cv_content)
|
| 702 |
-
st.download_button(
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
)
|
| 708 |
else:
|
| 709 |
st.error(cv_content)
|
| 710 |
|
|
@@ -819,7 +835,7 @@ elif page == "Career Insights":
|
|
| 819 |
days_back=7
|
| 820 |
current_date = datetime.now().strftime('%Y-%m-%d')
|
| 821 |
start_date = (datetime.now() - timedelta(days=days_back)).strftime('%Y-%m-%d')
|
| 822 |
-
if not isinstance(
|
| 823 |
raise ValueError("Invalid date format for from_param")
|
| 824 |
job_news = newsapi.get_everything(
|
| 825 |
q='(jobs OR hiring OR recruitment OR employment OR "job market") AND (India OR Indian)',
|
|
|
|
| 82 |
margin: 0 auto;
|
| 83 |
width: 150px;
|
| 84 |
}
|
| 85 |
+
|
| 86 |
.card {
|
| 87 |
background-color: #2d3748;
|
| 88 |
padding: 15px;
|
| 89 |
border-radius: 10px;
|
| 90 |
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
| 91 |
margin-bottom: 20px;
|
| 92 |
+
color: #ffffff !important;
|
| 93 |
+
}
|
| 94 |
+
.card h4 {
|
| 95 |
+
color: #ffffff !important;
|
| 96 |
+
margin-bottom: 10px;
|
| 97 |
+
}
|
| 98 |
+
.card p {
|
| 99 |
+
color: #e2e8f0 !important;
|
| 100 |
+
margin: 5px 0;
|
| 101 |
+
}
|
| 102 |
+
.card a {
|
| 103 |
+
color: #63b3ed !important;
|
| 104 |
+
text-decoration: none;
|
| 105 |
+
}
|
| 106 |
+
.card a:hover {
|
| 107 |
+
color: #90cdf4 !important;
|
| 108 |
}
|
|
|
|
| 109 |
|
| 110 |
[data-testid="stSidebar"],
|
| 111 |
.st-emotion-cache-6qob1r {
|
|
|
|
| 586 |
print(f"Error details: {str(e)}")
|
| 587 |
return f"Error generating CV: {str(e)}"
|
| 588 |
|
| 589 |
+
# def generate_cv_pdf(cv_content: str) -> BytesIO:
|
| 590 |
+
# try:
|
| 591 |
+
# # Initialize BytesIO buffer
|
| 592 |
+
# buffer = BytesIO()
|
| 593 |
|
| 594 |
+
# # Create a SimpleDocTemplate for the PDF
|
| 595 |
+
# doc = SimpleDocTemplate(buffer, pagesize=letter)
|
| 596 |
|
| 597 |
+
# # Define styles
|
| 598 |
+
# styles = getSampleStyleSheet()
|
| 599 |
+
# heading_style = ParagraphStyle(
|
| 600 |
+
# name='Heading',
|
| 601 |
+
# fontSize=14,
|
| 602 |
+
# leading=16,
|
| 603 |
+
# spaceAfter=12,
|
| 604 |
+
# fontName='Helvetica-Bold'
|
| 605 |
+
# )
|
| 606 |
+
# body_style = ParagraphStyle(
|
| 607 |
+
# name='Body',
|
| 608 |
+
# fontSize=11,
|
| 609 |
+
# leading=14,
|
| 610 |
+
# spaceAfter=8,
|
| 611 |
+
# fontName='Helvetica'
|
| 612 |
+
# )
|
| 613 |
+
# bullet_style = ParagraphStyle(
|
| 614 |
+
# name='Bullet',
|
| 615 |
+
# fontSize=11,
|
| 616 |
+
# leading=14,
|
| 617 |
+
# leftIndent=20,
|
| 618 |
+
# bulletIndent=10,
|
| 619 |
+
# spaceAfter=8,
|
| 620 |
+
# fontName='Helvetica'
|
| 621 |
+
# )
|
| 622 |
|
| 623 |
+
# # Initialize flowables list
|
| 624 |
+
# flowables = []
|
| 625 |
|
| 626 |
+
# # Validate cv_content
|
| 627 |
+
# if not cv_content or not isinstance(cv_content, str):
|
| 628 |
+
# logger.error("Invalid or empty cv_content provided")
|
| 629 |
+
# raise ValueError("CV content is empty or invalid")
|
| 630 |
|
| 631 |
+
# # Split content into sections
|
| 632 |
+
# sections = cv_content.split('===')
|
| 633 |
+
# logger.debug(f"Number of sections: {len(sections)}")
|
| 634 |
+
# logger.debug(f"Sections: {sections}")
|
| 635 |
|
| 636 |
+
# # Process sections
|
| 637 |
+
# for i in range(0, len(sections), 2):
|
| 638 |
+
# if i + 1 >= len(sections):
|
| 639 |
+
# logger.warning("Incomplete section pair detected, stopping processing")
|
| 640 |
+
# break
|
| 641 |
|
| 642 |
+
# title = sections[i].strip()
|
| 643 |
+
# content = sections[i + 1].strip().split('\n')
|
| 644 |
+
# logger.debug(f"Processing section: {title}")
|
| 645 |
|
| 646 |
+
# # Add section title
|
| 647 |
+
# flowables.append(Paragraph(title, heading_style))
|
| 648 |
+
# flowables.append(Spacer(1, 6))
|
| 649 |
|
| 650 |
+
# # Process section content
|
| 651 |
+
# if title in ["Skills", "Certifications"]:
|
| 652 |
+
# # Handle bullet points for Skills and Certifications
|
| 653 |
+
# bullet_items = []
|
| 654 |
+
# for line in content:
|
| 655 |
+
# if line.strip():
|
| 656 |
+
# # Sanitize text to avoid encoding issues
|
| 657 |
+
# sanitized_line = line.strip().encode('ascii', 'ignore').decode('ascii')
|
| 658 |
+
# bullet_items.append(ListItem(Paragraph(sanitized_line, bullet_style)))
|
| 659 |
+
# if bullet_items:
|
| 660 |
+
# flowables.append(ListFlowable(bullet_items, bulletType='bullet', start='circle'))
|
| 661 |
+
# else:
|
| 662 |
+
# logger.warning(f"No valid bullet items for section: {title}")
|
| 663 |
+
# else:
|
| 664 |
+
# # Handle regular paragraphs
|
| 665 |
+
# for line in content:
|
| 666 |
+
# if line.strip():
|
| 667 |
+
# # Sanitize text to avoid encoding issues
|
| 668 |
+
# sanitized_line = line.strip().encode('ascii', 'ignore').decode('ascii')
|
| 669 |
+
# flowables.append(Paragraph(sanitized_line, body_style))
|
| 670 |
|
| 671 |
+
# flowables.append(Spacer(1, 12))
|
| 672 |
|
| 673 |
+
# # Build the PDF
|
| 674 |
+
# logger.debug("Building PDF with flowables")
|
| 675 |
+
# doc.build(flowables)
|
| 676 |
|
| 677 |
+
# # Ensure buffer is ready to be read
|
| 678 |
+
# buffer.seek(0)
|
| 679 |
+
# logger.debug("PDF generation completed successfully")
|
| 680 |
|
| 681 |
+
# return buffer
|
| 682 |
|
| 683 |
+
# except Exception as e:
|
| 684 |
+
# logger.error(f"Error generating PDF: {str(e)}")
|
| 685 |
+
# raise Exception(f"Failed to generate PDF: {str(e)}")
|
| 686 |
|
| 687 |
with st.form("cv_form"):
|
| 688 |
col1, col2 = st.columns(2)
|
|
|
|
| 714 |
file_name="John_Doe_CV.txt",
|
| 715 |
mime="text/plain"
|
| 716 |
)
|
| 717 |
+
# pdf_buffer = generate_cv_pdf(cv_content)
|
| 718 |
+
# st.download_button(
|
| 719 |
+
# label="Download CV (PDF)",
|
| 720 |
+
# data=pdf_buffer,
|
| 721 |
+
# file_name="John_Doe_CV.pdf",
|
| 722 |
+
# mime="application/pdf"
|
| 723 |
+
# )
|
| 724 |
else:
|
| 725 |
st.error(cv_content)
|
| 726 |
|
|
|
|
| 835 |
days_back=7
|
| 836 |
current_date = datetime.now().strftime('%Y-%m-%d')
|
| 837 |
start_date = (datetime.now() - timedelta(days=days_back)).strftime('%Y-%m-%d')
|
| 838 |
+
if not isinstance(days_back, str):
|
| 839 |
raise ValueError("Invalid date format for from_param")
|
| 840 |
job_news = newsapi.get_everything(
|
| 841 |
q='(jobs OR hiring OR recruitment OR employment OR "job market") AND (India OR Indian)',
|