From 72964df794c686e501443fc1e98b01e0c57a9683 Mon Sep 17 00:00:00 2001 From: Gerardo Marx Date: Tue, 15 Jun 2021 01:13:53 +0000 Subject: [PATCH] reading html from file --- Readme.md | 19 +++++++++++++++++++ file-server.js | 13 +++++++++++++ index-static.html | 2 ++ 3 files changed, 34 insertions(+) create mode 100644 file-server.js create mode 100644 index-static.html diff --git a/Readme.md b/Readme.md index 3751971..675f3d2 100644 --- a/Readme.md +++ b/Readme.md @@ -19,3 +19,22 @@ server.listen(4040, ()=>{ }); ``` +## Server information on a html file + +```node +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('

Hello World

'); +}); + +server.listen(4040, ()=>{ + console.log('listen on http://beaglebone-black.local:4040'); +}); +``` +the contents of the .html file is a common file. + diff --git a/file-server.js b/file-server.js new file mode 100644 index 0000000..da894b3 --- /dev/null +++ b/file-server.js @@ -0,0 +1,13 @@ +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('

Hello World

'); +}); + +server.listen(4040, ()=>{ + console.log('listen on http://beaglebone-black.local:4040'); +}); diff --git a/index-static.html b/index-static.html new file mode 100644 index 0000000..150e617 --- /dev/null +++ b/index-static.html @@ -0,0 +1,2 @@ +

Hello World

+Here we are in my Beagle