以下範例利用Express實作WebServer

npm install express --save
npm install express-minify-html --save

Server.js
      const express = require('express');
      const app = express();
      
      const minifyHTML = require('express-minify-html');
      app.use(
          minifyHTML({
              override:      true,
              exception_url: false,
              htmlMinifier: {
                  removeComments:            true,
                  collapseWhitespace:        true,
                  collapseBooleanAttributes: true,
                  removeAttributeQuotes:     true,
                  removeEmptyAttributes:     true,
                  minifyJS:                  true
              }
          })
      );
      app.get('/', function(req, res) {
          res.send('

測試網頁

\n' + ' 歡迎光臨 \n
你好阿~'); }); var server = app.listen(8000, function() { console.log('Listening on port 8000'); });

酷米 © All Rights Reserved.

loading
Loading...