Can't open this page in nodejs? But I can open it directly with 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()

error clipboard.png

clipboard.png

Feb.28,2021

c.js also returns html, right? I don't see you make a difference.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e43946-59a95.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e43946-59a95.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?