'Is there an appropriate way to open a PDF from a temporary directory in a browser window using Python or is Javascript preferable?

I am currently generating a PDF from user input data on the Python side using ReportLab, after the PDF gets done generating it is saved using canvas.save() where it is saved temporarily into a directory such as 'static/tmp/example.pdf'. Currently, I just send the pdf to the user to save using return send_file(f"static/tmp/{example}.pdf", as_attachment=True) but I would like to be able to have this PDF open into a separate browser window where they can preview the PDF before saving it. I've tried a few methods with Python but no luck, is this feasible on the Python side, or would doing this on the Javascript side after the PDF is generated be more appropriate? Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source