Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 无法获取/ejs文件_Html_Node.js - Fatal编程技术网

Html 无法获取/ejs文件

Html 无法获取/ejs文件,html,node.js,Html,Node.js,我正在尝试用html完成调查页面的统计 当我尝试连接到该网页的ejs视图时,它给了我无法获取/显示结果的信息 // Entry point for the application // express application var express = require('express'); // require the controller we make var surveyController = require('./surveyController'); var app = exp

我正在尝试用html完成调查页面的统计 当我尝试连接到该网页的ejs视图时,它给了我无法获取/显示结果的信息

// Entry point for the application

// express application
var express = require('express');
// require the controller we make
var surveyController = require('./surveyController');

var app = express();

// set up template engine
app.set('view engine', 'ejs');

// static file serving
app.use(express.static('./public'));

// fire function from surveyController
surveyController(app);

// listen to port
app.listen(8080);
console.log('listening port 8080');


我有一个网页和app.js文件的HTML视图,似乎在控制台上运行,但当我登录到http://localhost:8080/showResults

在这里,您可以通过
app.js中的以下设置查看
ejs

// Entry point for the application

// express application
var express = require('express');
// require the controller we make
var surveyController = require('./surveyController');

var app = express();

// set up template engine
app.set('view engine', 'ejs');

// static file serving
app.use(express.static('./public'));

// fire function from surveyController
surveyController(app);

// listen to port
app.listen(8080);
console.log('listening port 8080');

// view engine setup

app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
//使用res.render加载ejs视图文件
app.get('/',函数(req,res){
res.render('/index');
});