wordpress - Node.js Express not rendering html view -
so trying follow tutorial use node.js front end of wordpress site
this 1 http://www.1001.io/improve-wordpress-with-nodejs/
here code server.js
var frnt = require('frnt'); var fs = require("fs"); var path = require("path"); var express = require('express'); var app = express(); var dot = require('express-dot'); // define public files are, in example ./public app.use(express.static(path.join(__dirname, 'public'))); // make sure set before frnt middleware, otherwise won't // able create custom routes. app.use(app.router); // setup frnt middleware link internal server app.use(frnt.init({ proxyurl: "http://localhost:8888/frnt-example/wordpress", // link wordpress site layout: false // simplify example not using layouts })); // define rendering engine app.set('views', path.join(__dirname, "views")); app.set('view engine', 'html' ); app.engine('html', dot.__express ); // respond "hello world!" on homepage app.get('/', function (req, res) { res.send('./views/index.html'); }); app.listen(8080); // listen port 8080
it keeps outputting following
./views/index.html
rather rendering html?
i've never used frnt, res.send sends string that's no big surprise.
look @ res.sendfile sends contents of file.
Comments
Post a Comment