尝试使用基本的哈巴狗模板设置基本的Express服务器。
你可以告诉我这里我做错了什么吗?addFlags()
我在控制台中找回'use strict';
//Require Express
var express = require('express');
var app = express();
//Require Pug
var pug = require('pug');
//Require Twitter
var Twitter = require('twitter');
//Set view engine to serve middleware
app.set('view engine', 'pug');
//Set where to look for templates
app.set('views', __dirname + '/templates');
//Set up style sheets
app.use('/static', express.static(__dirname + '/public'));
//Access keys to access twitter account
var config = {
"consumerKey": "",
"consumerSecret": "",
"accessToken": "",
"accessTokenSecret": ""
};
//instantiate twitter client
var client = new Twitter(config);
//Log whether
var error = function (err, response, body) {
console.log('ERROR [%s]', err);
};
var success = function (data) {
console.log('Data [%s]', data);
};
//Set up server on Port 3000
app.listen(3000, function() {
console.log("The frontend server is running on port 3000!");
});
//Render when appropriate
//Tell app to render template
app.get('/'), function(req, res){
res.render('index', {title: 'Hey', message: 'Hello there!'});
}
。
我错过了什么?
我非常感谢任何帮助
答案 0 :(得分:1)
您正在调用app.get()
错误。你在做什么
app.get('/'), function(req, res){
...
这是由逗号运算符分隔的两个语句。正确的语法是将函数作为第二个参数传递:
app.get('/', function(req, res){
...
});