Node.js quick file server (static files over HTTP)

前端 未结 30 1855
攒了一身酷
攒了一身酷 2020-11-22 12:30

Is there Node.js ready-to-use tool (installed with npm), that would help me expose folder content as file server over HTTP.

Example, if I have



        
30条回答
  •  盖世英雄少女心
    2020-11-22 13:19

    A simple Static-Server using connect

    var connect = require('connect'),
      directory = __dirname,
      port = 3000;
    
    connect()
      .use(connect.logger('dev'))
      .use(connect.static(directory))
      .listen(port);
    
    console.log('Listening on port ' + port);
    

    See also Using node.js as a simple web server

提交回复
热议问题