You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to write a complete application using restify, which would be mostly a webservice, but with a few (2-3) client. The issue is that I am unable to server simple static resources using restify as it automatically json-encodes them.
If file test.html contains 1234
Then
server.get('/',function(req,res){
fs.readFile('test.html','utf-8',function(err,data){
if(err){
res.send(100,{msg:"There was an error in handling your request"});
err.next();
}
else{
console.log(data);
res.send(200,data,{'Content-Type':'text/html; charset=utf-8'});
}
});
});
gives me "1234\n" as the output on opening localhost:8080/ on the browser.
I wanted to write a complete application using restify, which would be mostly a webservice, but with a few (2-3) client. The issue is that I am unable to server simple static resources using restify as it automatically json-encodes them.
If file
test.html
contains1234
Then
gives me "1234\n" as the output on opening
localhost:8080/
on the browser.I was able to make this work by following the example in http://mcavage.github.com/node-restify/restify-response.7.html but I feel that it should be easier to send simple html responses. (Instead of going around
res.write
)The text was updated successfully, but these errors were encountered: