Plotly Offline Mode Python Struggles

I am trying to nest a plotly chart within some html in a python cgi script. The example given in help(plotly.offline.plot):

from plotly.offline import plot
import plotly.graph_objs as go
plot([go.Scatter(x=[1, 2, 3], y=[3, 2, 6])], filename=‘my-graph.html’)

causes my page to error out. I cannot find any other examples of how to do this anywhere online. The remainder of the documentation is of the online use. Since the end game is to run this web app on a private network, I cannot use the online functionality.
Furthermore, the particular component I most strongly desire to use is the “output_type=‘div’” so that I can properly nest it within the html.
Any help would be greatly appreciated! :slight_smile:

I think i’ve figured it out. Still not sure why the above code isn’t working, however I have figured out how to get a graph nested in html online. Ill post my solution.

myChart = plotly.offline.plot({
“data”: [Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])],
“layout”: Layout(title=“hello world”, autosize=True)
},output_type=“div”, show_link=“False”,include_plotlyjs=“Flase”,link_text="")

print(myChart)

What I struggled so much with was not realizing that the plot function itself was returning the string. Once you assign it to a variable, you can just print out.