nodejs怎么把html以源码的形式在网页中显示了,而不是解析它。
 发布于 12 年前  作者 shen243212772  14724 次预览  最后一次回复是 12 年前  来自  

代码如下

var fs = require(‘fs’);

function start(response) { response.writeHead(200, {“Content-Type”: “text/plain”}); response.end(fs.readFileSync(__dirname + ‘/index.html’)); }

function upload(response) { response.writeHead(200, {“Content-Type”: “text/plain”}); response.end(fs.readFileSync(__dirname + ‘/index1.html’)); }

2 回复
shen243212772

想了下,原来是html文件头写错,改成 response.writeHead(200, {“Content-Type”: “text/html”}); 就好了

joecora

#为什么我render出来的文章列表是html以源码的形式在网页中呢,在html中被转义了,不知道如何解决,