Skip to content
Advertisement

I’m looking to connect a Google VM to a website

I need reflection, vision and documentation on my problem.

I wrote a python script to calculate something from an API and export the result in a CSV file. Then, I use a JavaScript script to display the data from this CSV file on a building website. I need to have the latest data available for my website, so I opened a VM instance in Google Cloud Platform (Google Compute Engine) and set a Crontab job to run automatically my python script. The calculation is now executed every day and the result is exported to the CSV file, but stored in this VM instance.

Here is my goal: How can I get my CSV file on my website? The CSV is always on the virtual machine and I do not know how to communicate with my JavaScript script to the VM. Do I have to communicate directly with the VM? Do I have to go through another step before (server, API, etc.)?

I cannot find a specific solution for my problem on the internet.

Thanks in advance.

Advertisement

Answer

How can I get my CSV file on my website?

By making your python script output the CSV into your website’s root folder.

Example, if you’re running apache, chances are your root folder is somewhere in /var/www/html/...

If the script is generated from another machine (not the one with your website), then I would host it and make the server hosting your website fetch it via cronjob.

Basically: If your CSV is generated from the same machine as the website that will use it – simply output it to the website’s folder

If your CSV is generated from another machine, make it publicly accessible and have your website’s machine cronjob fetch that CSV a few minute after it’s generated.

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