Click here to Skip to main content
15,038,237 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have this code
JavaScript
var fs= require("fs");
var http= require("http");

var server= http.createServer(function (request, response){

    if(request.url=="/")
    {
        fs.readFile("about.html",function(error, data){
            if(error){
                response.writeHead(202,{"content-type":"text\html"});
                response.end("sorry page not found");
            }
            else{
                response.writeHead(202,{"content-type":"text/html"});
                response.write(data)
                response.end();
            }

        });
    }
    else if(request.url=="about.html")
    {
        respsonse.end("about page requies rescevd");
        
    }

});
server.listen(4000,"127.0.0.1",function(error,data){
        if(!error)
        console.log("congragts");

    } )




On Browswer:
This working fine http://localhost:4000
but when doing request for this http://localhost:4000/about.html
(when typing and enter url it become hang (loading))

and finally show no data received. why ?
Posted
Updated 28-Oct-14 0:30am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900