aquavitae / docker-weasyprint Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
Can you confirm how the logs coming from weasyprint are processed? It seems to me all of them are hidden and we just get logs from gunicorn. Is there a way to reveal those? Is weasyprint's logging compatibble with the gunicorn logging?
I am using curl 7.52.1
. I find that what you have in the README.md
file does not work for me, but the following does.
curl -X POST \
-H Content-Type:text/html \
-T ./test.html http://127.0.0.1:5001/pdf?filename=test.pdf \
-o test.pdf
This uses -H
to set the Content-Type
, and -T
to upload the file. Because this is an example, I added -o
to store the response in a file that can be examined with a PDF reader.
Hi,
I'd love to use this for a project, but I can't seem get this to work after building locally. I can run your latest build using docker run -p 5001:5001 aquavitae/weasyprint
, which lets me successfully convert html to PDFs (tested via curl).
However when I clone the repo and build it myself (docker build . -t weasy && docker run -p 5001:5001 weasy
) the server boots and the health check URL works, but it errors out when using the same request that worked above.
[2016-10-15 04:41:54 +0000] [5] [INFO] Starting gunicorn 19.4.0
[2016-10-15 04:41:54 +0000] [5] [INFO] Listening at: http://0.0.0.0:5001 (5)
[2016-10-15 04:41:54 +0000] [5] [INFO] Using worker: sync
[2016-10-15 04:41:54 +0000] [8] [INFO] Booting worker with pid: 8
2016-10-15 04:42:05,008 INFO: POST /pdf?filename=unnamed.pdf [in /usr/src/app/wsgi.py:50]
2016-10-15 04:42:05,027 ERROR: Exception on /pdf [POST] [in /usr/local/lib/python3.5/site-packages/flask/app.py:1423]
Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/src/app/wsgi.py", line 51, in generate
html = HTML(string=request.data)
File "/usr/local/lib/python3.5/site-packages/weasyprint/__init__.py", line 92, in __init__
namespaceHTMLElements=False)
File "/usr/local/lib/python3.5/site-packages/html5lib/html5parser.py", line 35, in parse
return p.parse(doc, **kwargs)
File "/usr/local/lib/python3.5/site-packages/html5lib/html5parser.py", line 235, in parse
self._parse(stream, False, None, *args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/html5lib/html5parser.py", line 85, in _parse
self.tokenizer = _tokenizer.HTMLTokenizer(stream, parser=self, **kwargs)
File "/usr/local/lib/python3.5/site-packages/html5lib/_tokenizer.py", line 36, in __init__
self.stream = HTMLInputStream(stream, **kwargs)
File "/usr/local/lib/python3.5/site-packages/html5lib/_inputstream.py", line 151, in HTMLInputStream
return HTMLBinaryInputStream(source, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'encoding'
Has something changed upstream causing this to break? I tried modifying the Dockerfile to start from python:3.5.0-onbuild
and python:3.5.1-onbuild
with no luck. I don't have enough experience with Python to go further.
Maybe you can run the circle-ci build again to see if it's just my environment?
Thanks
weasyprint on console can also convert html to png file by just adding parameter -f png
this could be made available under the url:
/png/?filename=result.png
What do you think about it? I'm not that much into python to implement this - unfortunatly.
Thank you & greetings
Wolfgang
When I look in the requirements.txt file, I see that the weasyprint version is specified as version 51, which is what I hoped. However, when I start an interactive session using the following:
docker run -it -p 5001:5001 aquavitae/weasyprint /bin/bash
Then if I run the following command:
weasyprint --version
I get the following:
WeasyPrint version 0.31
Shouldn't I be seeing version 51 there?
Hello there
looks like the Dockerfile was updated recently, but the changes aren't rolled out to docker hub (https://hub.docker.com/r/aquavitae/weasyprint/tags).
Maybe it's worth noting that dockerhub provides a very convinient automation process for container builds. Is it possible for you @aquavitae to add this feature?
Here is a tutorial for this.
What is incomplete in this tutorial is versioned releases, which i would recommend so users don't get unintended updates. For the build rules, it could look like this:
This example config does the following:
Every commit on master -> rolled out to aquavitae/weasyprint:dev
Every release of a new version -> rolled out to aquavitae/weasyprint:latest
-> rolled out to aquavitae/weasyprint:{version}
Then, it's just necessary to make a new release in Github whenever a new version is released. This is as simple as:
The current fonts available are Deja Vu and Font Awesome, which lack support for Asian scripts. All discussion of CJK support for Deja Vu basically comes down to "it's a giant job, no one here can do it, and there's no readily available source we can take it from".
Debian's fonts page indicates that there are various specific fonts available, but a better option may be to install the Noto package, which brings in all of Google's Noto fonts that cover all scripts.
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.