Files

copied
Last update 6 years 2 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
watts.js
var express = require('express'); var app = express(); var http = require("http"); var httpServer = http.createServer(app); var clientSocket = require("socket.io-client"); var io = require('socket.io')(httpServer); var net = require("net"); var ioC = require('socket.io-client'); var host1 = "http://192.168.0.7:80"; var host2 = "http://45.76.237.136:80" var clientSocket = ioC.connect(host2, {reconnect: true}); var HOST = process.argv[2]; var PORT = 5555; var server = net.createServer({ 'encoding':'utf8'}, function(socket) { socket.setEncoding("utf-8"); socket.on("data", function (data) { if(data == data) { var apparentPW = Math.round(data*120) console.log(apparentPW); io.emit("watts",apparentPW); clientSocket.emit("watts",apparentPW); } }); }); server.listen(PORT,HOST); console.log("Server listening on " + HOST + ":" + PORT); app.use(express.static(__dirname + '/')); /* app.get('/', function(req, res) { res.sendFile(__dirname + '/temperatura.html'); }); */ app.get('/graph', function(req, res) { res.sendFile(__dirname + '/path.html'); }); httpServer.listen(3000, '0.0.0.0', function() { console.log('El servidor está listo...'); });
Report a bug