commit 747811f0f8e4ad44759c84f35f5a268a1241c179 Author: Gerardo Marx Date: Tue Jun 15 01:01:25 2021 +0000 static server diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..3751971 --- /dev/null +++ b/Readme.md @@ -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('

Hello World

'); +}); + +server.listen(4040, ()=>{ + console.log('listen on http://beaglebone-black.local:4040'); +}); +``` + diff --git a/package.json b/package.json new file mode 100644 index 0000000..59797d9 --- /dev/null +++ b/package.json @@ -0,0 +1,6 @@ +{ + "name": "socket-chat-example", + "version": "0.0.1", + "description": "my first socket.io app", + "dependencies": {} +} \ No newline at end of file diff --git a/static-server.js b/static-server.js new file mode 100644 index 0000000..ea85477 --- /dev/null +++ b/static-server.js @@ -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('

Hello World

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