Node.js distinguishes whether a file is requested or an interface.

const http=require("http")
const io=require("socket.io")
const mysql=require("mysql")
const fs=require("fs")
const url =require("url")

let  httpServer=http.createServer((request,response)=>{
    let {pathname,query}=url.parse(request.url,true)
    // truetruequeryjson
    if(pathname=="/reg"){
        console.log("")
    }else if(pathname=="/login"){
        console.log("")
    }else{
        console.log("")
        fs.readFile(`www${pathname}`,(err,data)=>{

        })
    }
})
httpServer.listen(8080)

when my browser typed http://localhost:8080/reg?user=abc12342&pass=a666666666, what I consoel.log out is the registration, file. Why is the "file" printed back?

Mar.14,2021

because there are two requests in the browser, one is the correct request as you think, and the other is to request the favicons small icon, so the 'file' will be printed.

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-1b37472-2c079.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-1b37472-2c079.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?