Files

39 lines
1.0 KiB
Python
Raw Permalink Normal View History

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__)
BUILD_VERSION = os.getenv('BUILD_VERSION', 'unknown')
GIT_COMMIT = os.getenv('GIT_COMMIT', 'unknown')
@app.route('/')
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({
'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)