在我的nodeJS完成功能之后,我正在尝试呈现index.html文件。但这告诉我他找不到模块HTML
这是nodeJS代码
var http = require ('http');
var fs = require('fs');
var port = 3000;
var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var jsFile = require('./src/GS1DigitalLinkToolkit');
var app = express();
var compressFunction = require('./compression');
var uncompressFunction = require('./decompression');
var router = express.Router();
var gs = require('./gs1');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:true}));
app.use(express.static(__dirname + '/files'));
app.set('views', __dirname + '/files');
app.set('view engine', 'html');
app.get('/', function(req,res){
res.sendFile('index.html', {root: path.join(__dirname, './files')})
})
app.post('/compression', function(req,resp){ //Post Response
var compression = req.body.compression;
var compressedLink = compressFunction.compressedDigitalLink(compression);
resp.render('files/index', {compressedDigitalLink :compressedLink});
});
我读到我需要添加:
app.set('views',__dirname +'/ files');
app.set('view engine','html');
我还应该添加什么?
谢谢您的帮助