mardi 29 septembre 2020

How to reference a randomly generated filename with flask

I am creating a program that generates a chart, and then displays the chart on the webpage. I want each chart generated to have a unique filename. However, once that unique filename is generated, I don't know how to refer to it within the html file.

I use this to create a random filename starting with "chart" in the "images" folder. This parts works fine.

basename = "images/chart"
suffix = str(uuid.uuid4())
filename = "_".join([basename, suffix])
plt.savefig(filename)

I then have this in the html file, but don't know how to modify to add the random suffix part of the name that was just generated.

<img src="">



Aucun commentaire:

Enregistrer un commentaire