node.js - Response not ending -




i'm creating frontend application 1 of our projects user, cluster, (single) node management, etc.

i've decided create frontend using html , javascript, , nodejs server-side functionality.

i've created webserver, can handle both defined routes , files; , i've decided split operations in functions. i've gathered javascript, parameters called value if they're not objects, , reference if objects?

if case, why can not end() request external function? , if can, how go this?

thanks!

code below reference.

// define server functionality     if (request.method === "get") {         // functions/routes go here         if (routes[request.url]) {             // route found!             // execute handler function             routes[request.url](request, response);         } else {             // no such route found in hashtable             // check if it's file             var filepath = __dirname + request.url;             if (fs.existssync(filepath)) {                 // it's file , found!                 //zomg!!!1!elf                 var mimetype = mime.contenttype(path.extname(filepath));                 var content = null;                 if (mimetype.indexof("text") > -1) {                     // file contains text                     content = fs.readfilesync(filepath, "utf-8");                 } else {                     // file binary                     content = fs.readfilesync(filepath);                 }                 //console.log(mimetype); // output mime type of each requested file                 response.statuscode = 200;                 response.setheader("content-type", mimetype === false ? "application/octet-stream" : mimetype);                 response.end(content);             } else {                 // file not found!                 console.log(`file ${filepath} not found!`);                 console.log("cannot serve null!");                 error404(request, response);             }         }     }  function error404(request, response) {     "use strict";      response.statuscode = 404;     response.end(); } 

found answer myself

typical symptom of little sleep. forgot restart server after modifying code.

facepalm





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -