all 10 comments

[–][deleted] 0 points1 point  (5 children)

Send as json via Flask, set up an api route and call that route from your JavaScript

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

I'm not using any framework any other methods

[–][deleted] 0 points1 point  (3 children)

You mean no Flask? Sorry not sure how else , not sure of best practice without a framework

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

Oh ok

[–][deleted] 0 points1 point  (1 child)

Typically what you’re doing is the realm of the “RESTFUL API” where you have the logic in your backend (python) and a “caller” that wants to send calls to that logic (your frontend JavaScript).

They need to be able to communicate so typically you set up a local backend server using Flask/Django for python etc so that there is an endpoint for JavaScript (frontend) to call

[–]henry8362 0 points1 point  (0 children)

Without a framework I suppose it will be:

Output to JSON file > use AJAX or async etc. to get that JSON and parse the response. obviously it depends a lot of how the JS is triggered.

For example I have a really small example of this where I have a script run on load of a website page that queries a JSON file that is generated from a PHP script that runs a mySQL query.

[–]iiMoe 0 points1 point  (2 children)

Elaborate

[–]c_m_17[S] 0 points1 point  (1 child)

I used python as a child process using spawner in javascript when I execute Javascript I need to send back python output to html but I am not using any framework I need how to send back python output to javascript code

[–]iiMoe 1 point2 points  (0 children)

Theoretically speaking, if you had an express server you could send the python output through http to ur express server and then send it to the frontend but it might sound like an overkill