No Description

index.js 1013B

1234567891011121314151617181920212223242526272829303132333435
  1. var winston = require('winston');
  2. var express = require('express');
  3. var expressLayouts = require("express-ejs-layouts")
  4. var router = express();
  5. var server = require('http').Server(router);
  6. var io = require('socket.io')(server);
  7. var bodyParser = require("body-parser");
  8. router.engine('html', require('ejs').renderFile);
  9. router.use(expressLayouts);
  10. router.set('view engine', 'html');
  11. router.use(bodyParser.urlencoded({ extended: true }))
  12. router.use(bodyParser.json());
  13. router.use(express.static('public'))
  14. server.listen(3100, function () {
  15. winston.info('Listening on port 3100');
  16. })
  17. router.get('/', function (req, res) {
  18. res.render('index', { title: 'The index page!' })
  19. });
  20. external_temperature_sensor = require('./external_temperature_sensor');
  21. relay_controller = require('./relay_controller');
  22. var channel = io
  23. .of('/')
  24. .on('connection', function (socket) {
  25. relay_controller.monitor(socket, channel);
  26. });
  27. relay_controller.start(router, channel);
  28. external_temperature_sensor.start(channel);