1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-05 16:37:47 +03:00
WeasyPrint/fireweasy/__init__.py
2012-02-14 12:49:33 +01:00

23 lines
513 B
Python

import os.path
from flask import Flask, render_template, jsonify
app = Flask(__name__)
@app.route('/')
def home():
return render_template('home.html')
@app.route('/sample.json')
def sample_json():
# Import late so that the HTTP server starts listening quickly.
from weasyprint.document import PDFDocument
from .serialize import serialize
sample = os.path.join(app.root_path, 'sample', 'sample.html')
document = PDFDocument.from_file(sample)
return jsonify(serialize(document))