D
D
Dima Sokolov2016-12-30 18:20:51
Node.js
Dima Sokolov, 2016-12-30 18:20:51

NodeJs not seeing files?

server.js:
var http = require('http');
var static = require('node-static');
varfile = new static.Server('.');
http.createServer(function(req, res) {
file.serve(req, res);
}).listen(8080);
console.log('Server running on port 8080');
The browser opens index.html from the root, it does not see the files in the folders.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
ckr, 2016-12-31
@dimka11

var static = require('node-static');

var fileServer = new static.Server('./public');

require('http').createServer(function (request, response) {
    request.addListener('end', function () {
        fileServer.serve(request, response);
    }).resume();
}).listen(8080);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question