Browse Source

reading html from file

master
parent
commit
72964df794
3 changed files with 34 additions and 0 deletions
  1. +19
    -0
      Readme.md
  2. +13
    -0
      file-server.js
  3. +2
    -0
      index-static.html

+ 19
- 0
Readme.md View File

@ -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('<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.

+ 13
- 0
file-server.js View File

@ -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('<h1> Hello World</h1>');
});
server.listen(4040, ()=>{
console.log('listen on http://beaglebone-black.local:4040');
});

+ 2
- 0
index-static.html View File

@ -0,0 +1,2 @@
<h1> Hello World</h1>
Here we are in my Beagle

Loading…
Cancel
Save