Browse Source

static server

master
commit
747811f0f8
3 changed files with 39 additions and 0 deletions
  1. +21
    -0
      Readme.md
  2. +6
    -0
      package.json
  3. +12
    -0
      static-server.js

+ 21
- 0
Readme.md View File

@ -0,0 +1,21 @@
# 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:
```node
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');
});
```

+ 6
- 0
package.json View File

@ -0,0 +1,6 @@
{
"name": "socket-chat-example",
"version": "0.0.1",
"description": "my first socket.io app",
"dependencies": {}
}

+ 12
- 0
static-server.js View File

@ -0,0 +1,12 @@
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');
});

Loading…
Cancel
Save