Files

copied
Last update 5 years 9 months by Daniel Urencio
Filesiot
..
YunCurrent
baseYun
eagle_files
nodemcu_energy
BebasNeue.otf
YunCurrent.ino
brainApp.js
cloudServer.js
localServer.js
package.json
path.html
path.js
tcpDS18B20.ino
temperatura.html
watts.js
cloudServer.js
var express = require("express"); var app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); var MongoClient = require('mongodb').MongoClient; MongoClient.connect('mongodb://localhost:27017',function(err,client) { const col = client.db('data').collection('watts'); io.on('connection', function (socket) { console.log('Socket.io connection established...'); socket.on('watts', function (data) { col.insert({ '_id':new Date().getTime(), 'watts':data }); io.emit('watts',data); }); }); }); app.use(express.static(__dirname + '/')); app.get('/graph', function(req, res) { res.sendFile(__dirname + '/path.html'); }); http.listen(80, function () { console.log('Server is running...'); });
Report a bug