Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const PORT = process.env.SERVER_PORT || 80;
- const fs = require('fs');
- const https = require('https');
- const express = require('express');
- const expressWs = require('express-ws');
- // const Kenwood = require('./libs/Kenwood');
- const privateKey = fs.readFileSync('keys/remote_wahgo_com.key', 'utf8');
- const certificate = fs.readFileSync('keys/remote_wahgo_com.crt', 'utf8');
- const app = express();
- const httpsServer = https.createServer({key: privateKey, cert: certificate}, app);
- expressWs(app, httpsServer);
- const getIndex = (req, res) =>{
- res.sendFile('/usr/app/public/index.html');
- }
- app.ws('/', function (ws, req) {
- ws.on('message', function (msg) {
- console.log(msg);
- });
- });
- app.get('/', getIndex);
- app.get('/index.html', getIndex);
- app.use(express.static('/usr/app/public'));
- app.get('*', getIndex);
- httpsServer.listen(PORT, function () {
- console.log('Server running on port ' + PORT + '.');
- });
- // const port = new Kenwood({dev:'/dev/tty-usbserial1'});
- // port.on('onZoneChannelData', console.log);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement