I
I
Ingerniated2017-03-10 14:36:06
Node.js
Ingerniated, 2017-03-10 14:36:06

What method is responsible for loading styles?

Tell me how to load styles in node?
fs.open(index.html);
we will get an html page, but how to make it load to it and its css with js?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan Polin, 2017-03-10
@Ingernirated

use express

var express = require('express'),  //подключаем модуль экспресса
   app = express(),
   http = require('http').Server(app);
   app.use(express.static('/public')); //подгружаем статику(папка где хранятся все css и js - файлы)
   app.get('/', function(req, res){
   res.sendFile(__dirname + '/index.html');
});
http.listen(3000, function(){
console.log('Сервер запущен'); // запускаем сервер
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question