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 to get it to pop up, but that does not work on the site.

I've tried following the example in, 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')

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?