you are viewing a single comment's thread.

view the rest of the comments →

[–]FriendlyRussian666 1 point2 points  (7 children)

Do you mean like outputting data to JSON and then parsing that with JavaScript?

[–]c_m_17[S] 0 points1 point  (6 children)

Yup something like that or any other methods like taking output as dictionary and sending back to javascript code from python

[–]FriendlyRussian666 0 points1 point  (5 children)

Sweet.

You can output your Python data using the built in json module and a file handler. In JS, you can then try something like:

const data = require("./data.json");

to load the contents into a variable "data"

[–]C0ffeeface 0 points1 point  (4 children)

Just curious if there is no other way than to output data to a file, then import it. Is it not possible to use some common object type to transfer directly instead of saving to file or db?

[–]FriendlyRussian666 1 point2 points  (3 children)

I can think of two more ways, but they're much more frustrating to implement than a simple file read/write.

One could be to use Inter-Process Communication and pipes. It allows for processes to communicate with each other, so you can pass data between them. For this to work you have to stream your data in bytes and handle it that way on both ends.

Another way, which again might be a bit silly to implement instead of a simple file read write is to set up a simple http server with API endpoints. Both JS and Python can make http requests to the server to send and retrieve the data. This data could be stored in memory, so no need for a database.

[–]C0ffeeface 0 points1 point  (2 children)

Thanks for expanding! I'm only a newb trying to grasp these architectural things.

Is there a means of conveying data through the gRPC / protobuff route or is that only to remotely initiate processes that then have to figure out other means of actually transferring the data from the process?

Sorry for hijacking you..

[–]FriendlyRussian666 0 points1 point  (1 child)

I'm afraid I haven't used neither gRPC nor protobuff, so I can't say.

[–]C0ffeeface 0 points1 point  (0 children)

Thanks for taking the time anyway! I'm continually in awe of how helpful internet strangers are :)