Skip to content
Advertisement

Returning plt.show() on HTML with Python Flask

I’m using Python Flask to take input from a simple html file. The HTML asks the user to input a state and when they do that I would like for the output to be a plot.

I have the following code that’s creating the Python Flask but when a user inputs a state, the plot outputs in my Jupyter Notebook file instead of on the HTML page.

I’ve seen methods using Figure() to get the plot to show on the HTML page but I’m not sure how to recreate my current plot using the figure function.

JavaScript

Here’s my HTML code, I know the plot needs to be in the output but not sure how to code it:

JavaScript

Advertisement

Answer

The Python Flask code:

JavaScript

The HTML code:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement