我使用Django+WeasyPrint生成HTML到PDF
在HTML模板中,我有大约10个SVG文件。在本地服务器上运行时,将HTML转换为PDF需要15秒。而在测试服务器(使用NGINX运行)中,它会超时。在WeasePrint中,我提到了我的测试URL(http//TEST.sampleproject)。com:8000)在基本url中。一旦我删除了基本的url,它会很快做出响应。但是图像没有加载
我的密码
html_string = render_to_string('sample.html', {'data': data})
result = HTML(string=html_string, base_url='http//test.sampleproject.com:8000').write_pdf(presentational_hints=True)
response = HttpResponse(result, content_type='application/pdf')
response['Content-Disposition'] = 'inline; filename={}'.format('sample.pdf')
return response
在我的模板文件中,我加载了大约10个图像。例如:“sample.html”模板文件:
<img src="{% static 'svg/Logo1.svg' %}" alt="" />
<img src="{% static 'svg/Logo2.svg' %}" alt="" />
在Docker容器中运行时抛出“504网关超时”
请帮我解决这个问题
目前没有回答
相关问题 更多 >
编程相关推荐