2026-04-19 17:56:01 +02:00
|
|
|
from flask import Flask, render_template, jsonify, send_file, request
|
|
|
|
|
from weasyprint import HTML
|
2026-04-19 17:09:21 +02:00
|
|
|
from datetime import datetime, timezone
|
|
|
|
|
import os
|
2026-04-19 17:56:01 +02:00
|
|
|
import io
|
2026-04-19 17:09:21 +02:00
|
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
|
|
|
|
BUILD_VERSION = os.getenv('BUILD_VERSION', 'unknown')
|
|
|
|
|
GIT_COMMIT = os.getenv('GIT_COMMIT', 'unknown')
|
|
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
|
def index():
|
|
|
|
|
return render_template('index.html')
|
|
|
|
|
|
2026-04-19 17:56:01 +02:00
|
|
|
@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'
|
|
|
|
|
)
|
|
|
|
|
|
2026-04-19 17:09:21 +02:00
|
|
|
@app.route('/health')
|
|
|
|
|
def health():
|
|
|
|
|
return jsonify({
|
|
|
|
|
'status': 'healthy',
|
|
|
|
|
'timestamp': datetime.now(timezone.utc).isoformat(),
|
|
|
|
|
'version': BUILD_VERSION,
|
|
|
|
|
'commit': GIT_COMMIT[:7] if GIT_COMMIT != 'unknown' else 'unknown'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
port = int(os.getenv('PORT', 5000))
|
|
|
|
|
app.run(host='0.0.0.0', port=port)
|