2

I have implemented an accelerometer Reader in python and I want to execute a function in a javascript file when a new value is read that will:
1 - update the value in a database
2 - broadcast the new value to all connected client ( via Socket.io)

I was wondering how to do it? I checked PyV8 but it seems not maintained and only working with Python 2.7. My files structure looks like

--JScode
----MyJSCode
--PythonCode
----MyPythonCode
7
  • 4
    Possible duplicate of How do I call a Javascript function from Python? Commented Sep 18, 2018 at 20:04
  • Sounds like an awful headache, but you may be able to get something working with pyqt Commented Sep 18, 2018 at 20:05
  • 2
    Can you use Node.js and call the node binary from Python? That's easier than evoking a script in a web browser binary Commented Sep 18, 2018 at 20:06
  • 1
    You can send messages between processes using pipes. Just have your node server listen for a message and have your Python program send them. Commented Sep 18, 2018 at 20:08
  • 1
    Yes, but from what I understood it's not possible to run a function located in another file with js2Py, all it does is just interpret function passed as strings Commented Sep 18, 2018 at 20:14

1 Answer 1

0

I managed to execute a python script from the javascript file using PythonShell (link to the npm page)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.