Steps to deploy Node.js to VPS using PM2 and Github Actions
git clone https://github.com/danielwetan/node1.git| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Hello World!</title> | |
| </head> | |
| <body> | |
| <h1>Hello World!</h1> | |
| <!-- All of the Node.js APIs are available in this renderer process. --> | |
| We are using Node.js <script>document.write(process.versions.node)</script>, |
| // based from https://github.com/justadudewhohacks/opencv4nodejs/tree/master/examples/simpleTracking1.js | |
| // This code is meant to be run on a Raspberry Pi 3 with the picamera. | |
| // NOTE: Before running this code, for OpenCV to detect the camera, you need to run sudo modprobe bcm2835-v4l2 | |
| // TODO: Write each detected frame to an image file somewhere, with the timestamp in the name | |
| const cv = require('opencv4nodejs'); | |
| const delay = 50; | |
| const hog = new cv.HOGDescriptor(); | |
| hog.setSVMDetector(cv.HOGDescriptor.getDefaultPeopleDetector()); |
This is the simplest implementation you will find for a client/server WebSockets architecture using socket.io.
To see a full explanation, read my answer on SO here: https://stackoverflow.com/a/24232050/778272.
If you're looking for examples using frameworks, check these links:
| // set-up a connection between the client and the server | |
| var socket = io.connect(); | |
| // let's assume that the client page, once rendered, knows what room it wants to join | |
| var room = "abc123"; | |
| socket.on('connect', function() { | |
| // Connected, let's sign-up for to receive messages for this room | |
| socket.emit('room', room); | |
| }); |