Forums

Plotly Graphs - Not Dash - but where to house graphs to embed in Wordpress

Hi all - I am trying to solve a particular issue - and it might be too specific but here goes:

  • I have a wordpress site (hosted elsewhere) that I have plotly graphs (currently hosted on plotly on their free community version)

  • The Plotly Community version has a limitation of 1,000 views a day (not sure if that is per account or per graph - but sent a note to them asking).....in anticipation/hopes that my wordpress site might exceed 1,000 - I wanted to figure out a solution on where to host the graphs (currently they are embedded as a iframe from plotly and put into a placeholder on my wordpress)

  • I have a python script that automates collecting/crunching of the data and putting into a plotly graph hosted on plotly which updates/overwrites (via python script) the previous file - which is then automatically updated on wordpress

  • I am trying to come up with an automated process (via python) to put the file potentially here (or elsewhere) to pull in via the same process.

Does anyone know how to use the above process to put the html file here on pythonanywhere and then iframe over to wordpress?

Thanks so much! Brian

Hi, answering the PythonAnywhere part of the question -- you can serve html file using static files mappings. We've got two help pages that might be useful here:

Fantastic - I will definitely try that!!! Greatly appreciated!

Thank you pafk! That works great - I still have to play around with the python script - but the basic structure on how to host the static html works perfectly!!!

Glad to hear that you made it work (at least basic structure)!

I had one follow up question:

Is there a way to programmatically save/overwrite files the reside on PythonAnywhere?

  • I have multiple html files that are updated daily (35 or so) that I would like to save to My_Files in Pythonanywhere

  • Ideally if there was a pythonic way to save the PythonAnywhere files (and overwrite the existing html files). In other words, I would like to tell my code (local on my machine) to save/overwrite the html files that are stored on PythonAnywhere

Thanks so much!!

There are a number of ways you can do that.

The very best would probably be to keep your files in a version control system like git, and then have a repository on GitHub or GitLab which contains the definitive version. When you made changes, you would use "git push" to push the changes to that remote repository, and you could schedule a daily task on PythonAnywhere to "git pull" the changes down.

If you don't want to get into the whole version control/git thing right now, an alternative way would be to use our API; that allows you to write reasonably simple Python code that can upload/download/list files on PythonAnywhere from a script running on your own machine. We have a blog post with the basics on how to get started using it.

Fantastic - I need to learn the Git side of things - that would really refine the process.

Thanks so much Giles - I will start to learn GIT to see if I can get that process down....if I get stalled out I'll check out the API

Thanks again Giles!

No problem, glad to help!