Search
 
SCRIPT & CODE EXAMPLE
 

HTML

reading html file and writing response.write nodejs

const http = require('http');
const fs = require('fs');

const hostname = '127.0.0.1';
const port = 3000;

fs.readFile('./index.html', (err, html) => {
    if(err){
        throw err;
    } else if(html){
    const server = http.createServer((req, res) => {
       res.statusCode = 200;
       res.setHeader('Content-type', 'text/html');
       res.write(html);    
       res.end();
    });
}
});


server.listen(port, hostname, () => {
    console.log('Server started on port ' + port);
});
Comment

PREVIOUS NEXT
Code Example
Html :: top bar html 
Html :: write python in html 
Html :: html check-box 
Html :: angular raw html 
Html :: usehistory is not exported from react-router-dom 
Html :: meta colors 
Html :: call to action phone number 
Html :: internal link css 
Html :: nuxt link relative path 
Html :: bootstrap row overflow 
Html :: ng for until number 
Html :: how to get image on the tab bar html 
Html :: Tailwind CSS rating stars 
Html :: html input size 
Html :: this src jqery 
Html :: arnav.tcode.in 
Html :: how to fix input field and disabled 
Html :: month and year picker bootstrap 
Html :: html time picker 
Html :: samp html 
Html :: html scroll div to top 
Html :: Translate html in magento 2 
Html :: html span title tooltip 
Html :: link css file 
Html :: input type for contact no 
Html :: negrita html 
Html :: index html example 
Html :: html video on end 
Html :: image html 
Html :: html input with icon right 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =