I am trying to generate pdf using pdfkit in flask . pdfkit is working fine in python but when i am using it in flask ,it is giving below error.
here is my flask code
from flask import Flask, make_response, request,render_template
import pdfkit
path_wkthmltopdf = r'C:\Python27\flaskapp\wkhtmltopdf\bin\wkhtmltopdf.exe'
config = pdfkit.configuration(wkhtmltopdf=path_wkthmltopdf)
app = Flask(__name__)
@app.route('/pdf', methods=['POST', 'GET'])
def pdf():
if request.method == 'POST':
my_string =request.form['text11']
pdf = pdfkit.from_string(my_string,False , configuration=config)
response=make_response(pdf)
response.headers['Content-Type'] = 'application/pdf'
response.headers['Content-Disposition'] = 'inline; filename=out.pdf'
return response
return render_template('pdff.html')
please help . please dont downvote .i have tried everything .but cound not found it solution
and sorry for my bad english
here is error
Traceback (most recent call last):
File "C:\Python27\flaskapp\flask\app.py", line 1687, in wsgi_app
response = self.full_dispatch_request()
File "C:\Python27\flaskapp\flask\app.py", line 1360, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Python27\flaskapp\flask\app.py", line 1358, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Python27\flaskapp\flask\app.py", line 1344, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Python27\flaskapp\main.py", line 17, in yout
pdf = pdfkit.from_string(my_string,False , configuration=config)
File "C:\Python27\flaskapp\pdfkit\api.py", line 68, in from_string
return r.to_pdf(output_path)
File "C:\Python27\flaskapp\pdfkit\pdfkit.py", line 92, in to_pdf
result = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
AttributeError: 'module' object has no attribute 'Popen'
This code won't run on Google App Engine, because App Engine's Python runtime environment doesn't allow calls to subprocess.Popen or any other call that starts another process.