How to create and download HTML file on the fly using React.Js/Python

What’s the best way to create a complex HTML/Excel/PDF file containing a table and a chartjs (React chartjs-2) graph and then download the file?
Should the HTML file be built using Python in the backend and then sent to the frontend or can the frontend do the job by itself?