在函数响应中,它将生成PDF
def export_to_pdf(disc):
print disc
rendered = render_template('specsheet.html', specs=disc)
css = ['templates/style.css']
pdf = pdfkit.from_string(rendered, False, css=css)
response = make_response(pdf)
response.headers['content-Type'] = 'application/pdf'
response.headers['content-Disposition'] = 'attachment; filename=output.pdf'
return response
def getproducts():
a = conn.cursor()
a.execute("SELECT * FROM `products` order by id asc")
getdatas = a.fetchall()
for x in range(0,len(getdatas)):
time.sleep(5)
disc = {
'name': getdatas[x][1], 'wattage': getdatas[x][2],
'lumens': getdatas[x][3], 'cct': getdatas[x][4],
'inputv': getdatas[x][5], 'powerfac': getdatas[x][6],
'efficacy': getdatas[x][7], 'cri': getdatas[x][8],
'projectedhr': getdatas[x][9],
'dimensions': getdatas[x][10], 'beamangle': getdatas[x][11],
'operatintemp': getdatas[x][12], 'certificates':getdatas[x][13],
'waterproof':getdatas[x][14], 'warranty': getdatas[x][15],
'ce': getdatas[x][16], 'dlc': getdatas[x][17],
'energy':getdatas[x][18], 'etl': getdatas[x][19],
'fcc':getdatas[x][20], 'rohs': getdatas[x][21],
'ul': getdatas[x][22], 'cul': getdatas[x][23],
'proimg': getdatas[x][24], 'dimen':getdatas[x][25]
}
export_to_pdf(disc)
return "Success"
export_to_pdf(disc)函数将生成一个pdf,但是在这种情况下,它将通过该函数,但是没有生成任何PDF