I have write a node js application which will use file system and read files but as I like the extension less url I make the system if you can't find the file with the request name as HTML than find as js and so on but as it writes PHP file it get's an error in cmd something like this
_http_outgoing.js:458
throw new TypeError('First argument must be a string or Buffer');
^
I test it out by disable all the other function and just let it read php file and as I enter it such as localhost:8080/home
and I have a home.php
file but it can't write it out, it has the same problem at reading files that aren't html such as js, text file. I want to ask how to solve it
here is the part of code that's reading php
function urlphp() {
var q = url.parse(req.url, true);
var filename = "." + q.pathname + ".php";
fs.readFile(filename, function(err, data) {
if (err) {
//urljs();
}
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(data);
return res.end();
});
}
the urljs();
function was the function that reads js file but in this case I disable it just to find out problems
via Andrew
No comments:
Post a Comment