An example of Socket.io with Node.Js on the beagle bone or Raspberry
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Gerardo Marx Chávez-Campos 72964df794 reading html from file 3 years ago
Readme.md reading html from file 3 years ago
file-server.js reading html from file 3 years ago
index-static.html reading html from file 3 years ago
package.json static server 3 years ago
static-server.js static server 3 years ago

Readme.md

Readme

This repository guides you to implement a server using Node.js. A first instance is created to understand how to set a server, then the server code is used to read the contents and printed out. Finally, a new server instance is prepared to prepare an index.html page and change dynamically its contents and LED status by reading the status option selected by the user.

Static server

A static server is developed on static-server.js file:

const express = require("express");
const app = express();
const http = require("http");
const server = http.createServer(app);

app.get('/', (req, res)=>{
        res.send('<h1> Hello World</h1>');
});

server.listen(4040, ()=>{
        console.log('listen on http://beaglebone-black.local:4040');
});

Server information on a html file

const express = require("express");
const app = express();
const http = require("http");
const server = http.createServer(app);

app.get('/', (req, res)=>{
        res.sendFile(__dirname + '/index-static.html');
        //res.send('<h1> Hello World</h1>');
});

server.listen(4040, ()=>{
        console.log('listen on http://beaglebone-black.local:4040');
});

the contents of the .html file is a common file.