在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ 在nodejs 打不開這個(gè)網(wǎng)頁?可是我直接用chrome 能打開

在nodejs 打不開這個(gè)網(wǎng)頁?可是我直接用chrome 能打開

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link href="./a.css" rel="stylesheet" type="text/css"/>

</head>
<body>
    <h1>我是好人啊</h1>
<script type="text/javascript" src="./c.js"></script>
</body>
</html>
var http = require('http')
var path = require('path')
var fs = require('fs')
var url = require('url')
var server = http.createServer(function(req, res){
    // console.log(req)
    // console.log(res)
    function staticRoot(){

        fs.readFile('./hello.html',function (err,fileContent){
    if(err){
        console.log(404)
        res.writeHead(404,'not found')
        res.end()
        }else{
             res.writeHead(200, 'OK')
             console.log('OK')
            res.write(fileContent)
            res.end()}
})}
        staticRoot()

報(bào)錯(cuò)clipboard.png
直接可以打開也有效果

clipboard.png

回答
編輯回答
擱淺

c.js也返回了html吧?沒見你有區(qū)分啊。

2018年5月17日 10:42