Hello,
I am new to node-red and trying to create a simple flow to change the image on click of button using raspberry pi2. I tried with the following nodes, but with no success.
The javascript is perfect as i tried the same ouside the node-red. Can anyone please help me to get it done. Below is the nodes and script I used in node-red
1. html in node (Method=GET, URL=/mypage)
2. template node
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Can Change Images</h1>
<button onclick="myFunction1()">On</button>
<button onclick="myFunction2()">Off</button>
<img id="myImage" src="pic_bulboff.gif" width="100" height="180">
<p>Click the light bulb to turn on/off the light.</p>
<script>
function myFunction1() {
var image = document.getElementById('myImage');
image.src = "pic_bulbon.gif";
}
function myFunction2() {
var image = document.getElementById('myImage');
image.src = "pic_bulboff.gif";
}
</script>
</body>
</html>
3. http response node
Note. When I hit the url
http://xx.xx.xx.xx:1880/mypage, the image is not displayed on the browser. When I try to view the image from browser, it says....Cannot GET /mypage/pic_bulboff.gif. I tried to coped the image on different paths, but didnt get the acutal path where i need to copy the image.
Thanks,
Jagtar