-1
我怎样才能得到我的应用程序的客户端的index.html?Index.html而不是客户端的东西在服务器端
索引页在server.js像这样定义
// load css styles
var css = '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> ';
css = css + '<style type="text/css">' +require('fs').readFileSync('./style.css').toString() + '</style>'
http.createServer(function (req, res) {
// send basic http headers to client
res.writeHead(200, {
"Content-Type": "text/html",
"Transfer-Encoding": "chunked"
});
// setup simple html page:
res.write("<html>\n<head>\n<title>Newsfeed</title>\n" +css +"</head>\n<body>");
但我想获得一个index.html这样我就可以使用纯HTML的前端。
这太大了,不能很好地回答这个问题,但是你需要编写单独的前端和后端。我更喜欢使用REST API将两者结合在一起,但将它们保存在单独的项目中(使用第三个共享库)。 – ssube
你已经用[express](http://stackoverflow.com/questions/tagged/express)标记了这个,所以不能回答你的问题吗? –