-1

I have this python method shown below in a separate file and want to access and get value using plain js (no frame works used.) is there any way i can achieve this?

def myPythonCode :
        ....
        ...
        return somevalue
  • https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API – Teemu Sep 26 '19 at 09:30
  • How and where are you running your javascript code, how and where are you running your python code? – Bergi Sep 26 '19 at 09:32
  • Read this https://stackoverflow.com/questions/13175510/call-python-function-from-javascript-code – Casper Sep 26 '19 at 09:33
  • Do you know about a client (JavaScript) - server (Python) side communication? It is best to do some research about how to do a client-server side communication through a web browser (or electron apps) with JavaScript first. – KarelG Sep 26 '19 at 09:34
  • You can try Ajax. – Risul Islam Sep 26 '19 at 09:36
  • Plain JS answer in [Call Python function from JavaScript code](https://stackoverflow.com/questions/13175510/call-python-function-from-javascript-code) is [right here](https://stackoverflow.com/a/13175651/557019) – James Long Sep 26 '19 at 09:42
  • for this i should use flask and run it as server right? – JithilPrakash Sep 26 '19 at 11:27

1 Answers1

0

You can use python wrapper for google V8 engine called PyV8

It act as a bridge between the Python and JavaScript objects, and support to hosting Google's v8 engine in a python script.

  • i dont want to do any changes in python code. just plain js. i want to use scipy.spatial package, since js doesnt have anything. i used python for that and now i want to integrate python code with my plain js – JithilPrakash Sep 26 '19 at 11:28