Server-Side Plotly Graphs with Python and HTML

WellConnectedEpitaph avatar
WellConnectedEpitaph
·
·
Download

Start Quiz

Study Flashcards

10 Questions

What should you do in your html template file for your results page?

Create a placeholder for your plot code

What template engine does Flask use?

Jinja

What type of request will you likely be processing in your Flask views.py file to create the plotly graph?

POST data

How should you render the template with the plot code inserted into the div_placeholder variable?

In your Flask views.py file

What is the author's main goal for building the offline application?

To build the graph at the server side (backend) and then display the data in HTML at the front end.

What technology is the author using for the backend of the application?

Python (Flask)

What technology is the author using for the frontend of the application?

HTML (Javascript)

What module does the author suggest using to create an offline version of a plot?

plotly.offline module

What does the offline.plot function in plotly take as a kwarg?

output_type, which is either 'file' or 'div'

How does the author suggest to insert the plot code into HTML?

By using the offline.plot function to get the code (wrapped in tags) to insert straight into the HTML.

Study Notes

  • The text discusses the process of building an offline application using Plotly for displaying graphs with Python (Flask) at the back end and HTML (JavaScript) for the front end.
  • The author mentions that they are currently able to plot graphs on the front end using Plotly.js, but they want to build the graphs at the back end and then display the data on the front end.
  • The author has looked into the Plotly documentation for building graphs in Python, but they're unsure of how to send the built graph to the front end for display.
  • The suggested solution is to use Plotly's offline module, which creates an offline version of a plot. This module uses a kwarg for output_type, which can be set to 'file' or 'div'.
  • To insert the div into HTML code using Flask, the author suggests creating a placeholder for the plot code in the HTML template file, rendering the template with the plot code inserted into the placeholder in the Flask views file, and processing user requests using POST data to create the Plotly graph.

Learn how to build and display Plotly graphs on the server side using Python (Flask) for backend and HTML (Javascript) for frontend. Explore the process of generating the graph at the backend and sending the data to be displayed in HTML.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free
Use Quizgecko on...
Browser
Browser