Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,70 +1,54 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
-
|
| 4 |
-
from
|
| 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 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
return "\n".join(logs)
|
| 56 |
-
|
| 57 |
-
# Gradio UI
|
| 58 |
-
iface = gr.Interface(
|
| 59 |
-
fn=process_and_send,
|
| 60 |
-
inputs=[
|
| 61 |
-
gr.File(label="π Upload CSV of Applicants", file_types=[".csv"]),
|
| 62 |
-
gr.Text(label="π§ Your Email (Gmail)", placeholder="example@gmail.com"),
|
| 63 |
-
gr.Text(label="π Your Email Password or App Password", type="password"),
|
| 64 |
-
],
|
| 65 |
-
outputs="text",
|
| 66 |
-
title="AI-Powered Mailing System (No API Key Needed)",
|
| 67 |
-
description="Upload your applicant CSV and send personalized emails using Hugging Face FLAN-T5 model.",
|
| 68 |
-
)
|
| 69 |
-
|
| 70 |
-
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import base64
|
| 3 |
+
import pdfkit
|
| 4 |
+
from jinja2 import Template
|
| 5 |
+
|
| 6 |
+
# Load HTML template
|
| 7 |
+
with open("template.html", "r", encoding="utf-8") as f:
|
| 8 |
+
template_html = f.read()
|
| 9 |
+
|
| 10 |
+
def generate_resume(name, job_title, email, phone, summary, skills, education, experience, photo):
|
| 11 |
+
photo_base64 = ""
|
| 12 |
+
if photo is not None:
|
| 13 |
+
photo_base64 = base64.b64encode(photo.read()).decode('utf-8')
|
| 14 |
+
|
| 15 |
+
data = {
|
| 16 |
+
"name": name,
|
| 17 |
+
"job_title": job_title,
|
| 18 |
+
"email": email,
|
| 19 |
+
"phone": phone,
|
| 20 |
+
"summary": summary,
|
| 21 |
+
"skills": [s.strip() for s in skills.split(",")],
|
| 22 |
+
"education": [e.strip() for e in education.split(";")],
|
| 23 |
+
"experience": [x.strip() for x in experience.split(";")],
|
| 24 |
+
"photo_base64": photo_base64
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
template = Template(template_html)
|
| 28 |
+
rendered_html = template.render(**data)
|
| 29 |
+
|
| 30 |
+
with open("resume_output.html", "w", encoding="utf-8") as f:
|
| 31 |
+
f.write(rendered_html)
|
| 32 |
+
|
| 33 |
+
pdfkit.from_file("resume_output.html", "resume.pdf")
|
| 34 |
+
return "resume.pdf"
|
| 35 |
+
|
| 36 |
+
inputs = [
|
| 37 |
+
gr.Text(label="Full Name"),
|
| 38 |
+
gr.Text(label="Job Title"),
|
| 39 |
+
gr.Text(label="Email"),
|
| 40 |
+
gr.Text(label="Phone"),
|
| 41 |
+
gr.Textbox(label="Professional Summary", lines=4),
|
| 42 |
+
gr.Textbox(label="Skills (comma-separated)"),
|
| 43 |
+
gr.Textbox(label="Education (separate with ; )"),
|
| 44 |
+
gr.Textbox(label="Experience (separate with ; )"),
|
| 45 |
+
gr.File(label="Upload Profile Photo (Optional)", type="binary")
|
| 46 |
+
]
|
| 47 |
+
|
| 48 |
+
gr.Interface(
|
| 49 |
+
fn=generate_resume,
|
| 50 |
+
inputs=inputs,
|
| 51 |
+
outputs=gr.File(label="π Download Resume PDF"),
|
| 52 |
+
title="π§ AI Resume Builder",
|
| 53 |
+
description="Enter your details and generate a polished PDF resume instantly."
|
| 54 |
+
).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|