Skip to content

How to Run a Python Script from a Nuxt.js SPA?

I am currently working on a Nuxt.JS SPA. One of the feature is uploading, downloading, and deleting files from a cloud storage. I’ve already successfully done so using Google’s Firebase products and API because google has it in Node.JS.

Now I have to change the storage to a Ceph storage. The issue is, I have to do this using Ceph’s Object Gateway S3 API. But, Ceph doesn’t have this in JS, Node.JS, etc.. I can use Python to do implement them and I have created Python script(s) that could do just that.

Now, I have to somehow call these Python scripts from my SPA and run them when a button is clicked. I know that a python script could be called from Node.JS or Javascript using child_process or NPM modules like python-shell that uses child_process and something like this would be ideal for me.

The issue is, because it is SPA and mostly client-side, I can’t use child process because it is apparently server-side (I have tried them and I keep getting “can’t resolve child_process” errors). So the solutions offered in the other question (How to call a Python function from Node.js) DOESN’T work for me.

Are there any other alternatives or solutions that I could possibly try to solve this issue other than let’s say using AWS Lambda or similar solutions? Or am I just pointlessly bashing my head against a wall?

I’m new with Node.JS, Nuxt, etc. so I’m sorry if I wrote something nonsensical.



You need to create an http ( easiest) api for you python script.

So your SPA will send http request to your python script, and python script do a job. And yes, you need some kind of server or lambda or whatever for this.

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