ciricihq / wkhtmltopdf-flask-aas Goto Github PK
View Code? Open in Web Editor NEWWkhtmltopdf Flask As a Service
License: GNU General Public License v3.0
Wkhtmltopdf Flask As a Service
License: GNU General Public License v3.0
Current result: blank or black pages instead expected content. May be need wait few seconds (for page loading and script execution) before rendering?
I got the following UnicodeEncodeError:
[2017-03-10 13:21:05,861] ERROR in app: Exception on /pdf [POST]
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1988, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1641, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1544, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1639, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1625, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "app.py", line 15, in pdf
doc = handle_request(config)
File "app.py", line 44, in handle_request
pdf = pdfkit.from_string(str(request.form['html']), output_path=False, configuration=config, options=options)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)
This is how I did the request:
response = requests.post(
'http://localhost:5000/pdf', data={
'html': 'áááááá',
'options': {'encoding': 'UTF-8'},
})
Any advices?
When you configure health checks in docker/kubernetes/whatever the log gets "spammed" with these requests.
It would be neat to filter that from the requestlogging.
I don't know the stack, so I have no clue where to start.
I was able to add a simple health endpoint by adding
@app.route("/health", methods=['GET'])
def health():
return Response("{healthy: 'true'}", mimetype='application/json')
to the app.py, but I don't know where to skip the access-log for the endpoint.
BTY: a health endpoint is a good idea, even docker itself supports that now
Hi! I love your work. I am trying to make page numbers alternately appear at the bottom left for odd pages and bottom right for even pages. Is there a way to do that?
What I have so far is this...
wkhtmltopdf_path = 'C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe'
config = pdfkit.configuration(wkhtmltopdf=wkhtmltopdf_path)
options = {
'footer-center': '~ [page] of [topage] ~',
We should provide some testing using travis-ci
The current size is 830MB, it should be smaller
Add logs to flask in order to know what is happening when the microservice is in production server.
I got the following error when generating a PDF from HTML with the "alpine" tag:
[2022-05-20 08:10:41,195] ERROR in app: Exception on /pdf [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "app.py", line 15, in pdf
doc = handle_request(config)
File "app.py", line 44, in handle_request
pdf = pdfkit.from_string(unicode(request.form['html']), output_path=False, configuration=config, options=options)
NameError: name 'unicode' is not defined
I tried with the docker image with "latest" tag based on Debian, it works as expected.
How can I update the dockerfile or app.py to make it works also on alpine?
https://hub.docker.com/r/ciricihq/wkhtmltopdf-aas Updated a year ago
Current wkhtmltopdf version in image: 0.12.2.1 (3 years old)
Latest version: 0.12.5
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.