Node.js Generate html

前端 未结 4 1997
醉话见心
醉话见心 2020-12-02 11:17

I have created a JavaScript program which generates a list of data. Example output below:

output one 
output two 
output three 
...

I would

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-02 11:56

    Although @yanick-rochon answer is correct, the simplest way to achieve your goal (if it's to serve a dynamically generated html) is:

    var http = require('http');
    http.createServer(function (req, res) {
      res.write('');
      res.write('

    Write your HTML content here

    '); res.end(''); }).listen(1337);

    This way when you browse at http://localhost:1337 you'll get your html page.

提交回复
热议问题