我的5页网站上的所有页面都应该使用Node.js服务器输出.
大多数页面内容都是静态的.在每个页面的底部,都有一些动态内容.
我的node.js代码目前看起来像:
var http = require('http');
http.createServer(function (request, response) {
console.log('request starting...');
response.writeHead(200, { 'Content-Type': 'text/html' });
var html = '<!DOCTYPE html><html><head><title>My Title</title></head><body>';
html += 'Some more static content';
html += 'Some more static content';
html += 'Some more static content';
html += 'Some dynamic content';
html += '</body></html>';
response.end(html, 'utf-8');
}).listen(38316);
Run Code Online (Sandbox Code Playgroud)
我确信这个例子有很多不妥之处.请赐教!例如:
node.js ×1