V
V
Vitaliy Rokossovyk2016-02-02 23:10:38
Node.js
Vitaliy Rokossovyk, 2016-02-02 23:10:38

How to connect a script to a page?

There is a server which gives page on url. How to connect .js .css files to this page without express.js?

http.createServer(function(req,res){
  switch(req.url){
    case '/':
    fs.readFile('index.html',function(err,data){
      if (err) throw err;
      res.writeHead(200,{'Content-Type': 'text/html'});
      res.end(data);
    });
    break;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2016-02-02
@By_Engine

require(...);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question