From c3946fc53295bae0241569f0565cc37d3a6a187f Mon Sep 17 00:00:00 2001 From: Hrishikesh Uchake Date: Sun, 25 Jan 2026 12:52:01 -0600 Subject: [PATCH] Add missing resume preview and download API endpoints to production server --- app_production.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/app_production.py b/app_production.py index 66b7881..ef72f78 100644 --- a/app_production.py +++ b/app_production.py @@ -752,6 +752,51 @@ def get_user_resumes(user_id): return jsonify({"error": "INTERNAL_ERROR", "message": str(e)}), 500 +@app.route("/api/v1/user/resumes/download/", methods=["GET"]) +def download_resume(resume_id): + """Download a previously generated resume PDF""" + try: + from database.repositories import ResumeRepository + resume = ResumeRepository.get_resume(resume_id) + if not resume or not resume.pdf_path: + return jsonify({"error": "Resume not found"}), 404 + + if not os.path.exists(resume.pdf_path): + return jsonify({"error": "PDF file not found on server"}), 404 + + return send_file( + resume.pdf_path, + mimetype="application/pdf", + as_attachment=True, + download_name=f"resume_{resume.job_title.replace(' ', '_')}.pdf" + ) + except Exception as e: + logger.error(f"Failed to download resume: {e}", exc_info=True) + return jsonify({"error": "INTERNAL_ERROR", "message": str(e)}), 500 + + +@app.route("/api/v1/user/resumes/preview/", methods=["GET"]) +def preview_resume(resume_id): + """Preview a previously generated resume PDF inline""" + try: + from database.repositories import ResumeRepository + resume = ResumeRepository.get_resume(resume_id) + if not resume or not resume.pdf_path: + return jsonify({"error": "Resume not found"}), 404 + + if not os.path.exists(resume.pdf_path): + return jsonify({"error": "PDF file not found on server"}), 404 + + return send_file( + resume.pdf_path, + mimetype="application/pdf", + as_attachment=False + ) + except Exception as e: + logger.error(f"Failed to preview resume: {e}", exc_info=True) + return jsonify({"error": "INTERNAL_ERROR", "message": str(e)}), 500 + + @app.route("/api/v1/user/applications/", methods=["GET"]) def get_user_applications(user_id): """Get all job applications for a user"""