Nav apraksta

index.js 1013B

    var winston = require('winston'); var express = require('express'); var expressLayouts = require("express-ejs-layouts") var router = express(); var server = require('http').Server(router); var io = require('socket.io')(server); var bodyParser = require("body-parser"); router.engine('html', require('ejs').renderFile); router.use(expressLayouts); router.set('view engine', 'html'); router.use(bodyParser.urlencoded({ extended: true })) router.use(bodyParser.json()); router.use(express.static('public')) server.listen(3100, function () { winston.info('Listening on port 3100'); }) router.get('/', function (req, res) { res.render('index', { title: 'The index page!' }) }); external_temperature_sensor = require('./external_temperature_sensor'); relay_controller = require('./relay_controller'); var channel = io .of('/') .on('connection', function (socket) { relay_controller.monitor(socket, channel); }); relay_controller.start(router, channel); external_temperature_sensor.start(channel);