How can I use something similar to pyplot to show a wordcloud on a website made in flask?

I'm setting up a website with flask, where you pass a json to the site and it shows a graphic of a wordcloud based off of the json. In my command line tool, I used pyplot.show() to get it to pop up, but that does not work on the site.

I've tried following the example in https://matplotlib.org/3.1.1/faq/howto_faq.html#howto-webapp, but I can't even get that to run, I get an attribute error.

In my command line tool, I used

    wordcloud = WordCloud(background_color = 'white', sca1e =5).generate_from_frequencies(frequencies = d)

    plt.imshow(wordcloud, interpolation = 'bilinear')
    plt.axis("off")
    plt.show()

where d is a dictionary of words as keys and frequencies as values. Obviously, this does not work in flask.

I want it to show a wordcloud, but it just returns an error. Does anyone know how I'd go about doing this in flask?