0

I am not able to add css and js file please give me a code by which i can use my css or other files This is my code:

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

const port = 3000;
fs.readFile('index.html',(err,html) => {
    if(err){
        throw err;
    }

    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)
    });
});


my file location is
test.js
index.html
public /css==>here my css files
       /js ==>here my other js files
6
  • Possible duplicate of Node.js - external JS and CSS files (just using node.js not express) Commented Mar 31, 2017 at 5:49
  • by using this also my css file not included =>> Node.js - external JS and CSS files (just using node.js not express) Commented Mar 31, 2017 at 6:09
  • @ashwinichavan try to use express Commented Mar 31, 2017 at 17:13
  • i got answer..thanku all Commented Apr 2, 2017 at 12:25
  • @ashwinichavan if you were able to resolve your issue, would you mind to post the answer here and accept it ? so that it can help others as well. Commented Apr 3, 2017 at 12:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.