Re: ChatGPT

Posted by OmegaKV on
URL: https://mikraite.arkian.net/ChatGPT-tp3051p3053.html

I asked it to make a website in python that generates a PDF resume given a name, education, and work experience and this is what it gave:

from flask import Flask, request, make_response
from fpdf import FPDF

app = Flask(__name__)

def generate_pdf(name, education, work_experience):
    pdf = FPDF()
    pdf.add_page()
    pdf.set_font("Arial", size=12)
    pdf.cell(200, 10, txt=f"Resume for {name}", ln=1, align="C")
    pdf.cell(200, 10, txt="Contact Information:", ln=1, align="L")
    pdf.cell(200, 10, txt=f"Name: {name}", ln=1, align="L")
    pdf.cell(200, 10, txt="Email: your_email@example.com", ln=1, align="L")
    pdf.cell(200, 10, txt="Phone: (555) 555-5555", ln=1, align="L")
    pdf.cell(200, 10, txt="Summary:", ln=1, align="L")
    pdf.cell(200, 10, txt=f"A highly motivated individual with experience in {work_experience} and education in {education}.", ln=1, align="L")
    pdf.cell(200, 10, txt="Education:", ln=1, align="L")
    pdf.cell(200, 10, txt=education, ln=1, align="L")
    pdf.cell(200, 10, txt="Work Experience:", ln=1, align="L")
    pdf.cell(200, 10, txt=work_experience, ln=1, align="L")
    response = make_response(pdf.output(dest='S').encode('latin1'))
    response.headers.set('Content-Disposition', 'attachment', filename='resume.pdf')
    response.headers.set('Content-Type', 'application/pdf')
    return response

@app.route("/", methods=["GET", "POST"])
def index():
    if request.method == "GET":
        return '''
        <form method="post">
          Name: <input type="text" name="name"><br>
          Education: <input type="text" name="education"><br>
          Work Experience: <input type="text" name="work_experience"><br>
          <input type="submit" value="Submit">
        </form>
        '''
    else:
        name = request.form["name"]
        education = request.form["education"]
        work_experience = request.form["work_experience"]
        return generate_pdf(name, education, work_experience)

if __name__ == "__main__":
    app.run()