Answer the question
In order to leave comments, you need to log in
How to display a pdf file on a new page?
Good afternoon.
The essence of the question is this: when a user clicks on a button, you need to open a new browser tab and display a pdf file on it, without changing the page on which this button was clicked.
PS I tried to redirect the user to a new url through redirect, and there already open a new tab. Through this method, a POST request is sent, but for some reason the new url accepts GET and therefore I cannot output the pdf file only if the html template.
Answer the question
In order to leave comments, you need to log in
Or I didn't understand something. But this seems to be done at the html level with target="_blank"
<a href="http://example.com" target="_blank">go</a>
from flask import send_file
return send_file(report_file_pdf, as_attachment=True)
An appropriate Content-Disposition HTTP header must be specified
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question