这是我的文件夹结构
static
templates
wkhtmltopdf
app.py
Procfile
requirements.txt
runtime.txt
这是我在app.py中写的
from flask import Flask, render_template, request, redirect, make_response
import pdfkit
config = pdfkit.configuration(wkhtmltopdf="./wkhtmltopdf/bin/wkhtmltopdf.exe")
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/form', methods=['GET', 'POST'])
def form():
if request.method == 'POST':
name = request.form.get('name')
email = request.form.get('email')
number = request.form.get('number')
res = render_template('generatepdf.html', name=name, email=email, number=number)
responsestring = pdfkit.from_string(res, False, configuration=config)
response = make_response(responsestring)
response.headers['Content-Type'] = 'application/pdf'
response.headers['Content-disposition'] = 'inline;filename=test.pdf'
return response
else:
return render_template('form.html')
if __name__ == '__main__':
app.run(debug=True)
这是我在Requirements.txt中写的
click==7.1.2
django-wkhtmltopdf==3.3.0
Flask==1.1.2
gunicorn==20.0.4
itsdangerous==1.1.0
Jinja2==2.11.2
MarkupSafe==1.1.1
pdfkit==0.6.1
six==1.15.0
Werkzeug==1.0.1
wkhtmltopdf==0.2
我在heroku日志中得到了这个
2020-07-14T14:12:40.249773+00:00 app[web.1]: PermissionError: [Errno 13] Permission denied: './wkhtmltopdf/bin/wkhtmltopdf.exe'
我正在我的网页上找到它
在本地计算机上一切正常,但是我应该怎么做才能使wkhtmltopdf在heroku上工作