feat: tilføj rigtig PDF download via WeasyPrint
All checks were successful
Build and Deploy Erika CV / build-and-deploy (push) Successful in 58s

- /download route genererer PDF server-side
- PDF ser ud som hjemmesiden (ikke browser-print)
- Kompakt print-CSS til 1 A4-side
- Knap downloader direkte i stedet for at åbne print-dialog
This commit is contained in:
Henrik Jess Nielsen
2026-04-19 17:56:01 +02:00
parent 63f5fb4555
commit ff48f31ae5
4 changed files with 63 additions and 20 deletions

15
app.py
View File

@@ -1,6 +1,8 @@
from flask import Flask, render_template, jsonify
from flask import Flask, render_template, jsonify, send_file, request
from weasyprint import HTML
from datetime import datetime, timezone
import os
import io
app = Flask(__name__)
@@ -11,6 +13,17 @@ GIT_COMMIT = os.getenv('GIT_COMMIT', 'unknown')
def index():
return render_template('index.html')
@app.route('/download')
def download_pdf():
html = render_template('index.html', pdf_mode=True)
pdf = HTML(string=html, base_url=request.host_url).write_pdf()
return send_file(
io.BytesIO(pdf),
mimetype='application/pdf',
as_attachment=True,
download_name='Erika_Nielsen_CV.pdf'
)
@app.route('/health')
def health():
return jsonify({