I'm trying to make a program that reads a JSON string from a javascript file, and I just can't seem to do it. I can only the opposite of what I want. Here is my code
#python 2.7?
import sys
from subprocess import Popen, PIPE
messages = [] #store messages from send.js
sensor = Popen([communication.html, send.js])
buffer = b''
while True:
# read the sensor a character at a time
out = sensor.stdout.read(1)
#after reading
if out = b'\n':
messages.append(float(buffer))
print(messages)
buffer = b''
else:
buffer += out #append to buffer
//javascript
function sendMsg(){
var msg = document.getElementById('talk').value;
var data = {
"sending": msg
};
data = JSON.stringify(data)
}
<!DOCTYPE html>
<html>
<head>
<!--<script src="comScrp.py"></script>-->
</head>
<body>
<script src="send.js"></script>
<!--Without the Python, we wouldn't be able to use this without a server or nodeJs.-->
<input id="talk"><button onclick="sendMsg()">Send</button>
<p id="output"></p>
</body>
</html>
Thanks!