handler.js 846 B

123456789101112131415161718192021222324252627282930313233
  1. var Handler = {
  2. // getViewPath:function(path){
  3. // var request = URL.parse(VIEWSPATH+path,true);
  4. // var FileName = request.pathname+'.html';
  5. // if(FILE.existsSync(FileName)){
  6. // return FileName;
  7. // }else{
  8. // return null;
  9. // }
  10. // },
  11. // getView:function(path){
  12. // var FileName = this.getViewPath(path);
  13. // if(FileName){
  14. // return FILE.readFileSync(FileName,'utf8');
  15. // }else{
  16. // return null;
  17. // }
  18. // },
  19. response:function(res,data){
  20. },
  21. apiResponse:function(res,data){
  22. if(!res) return;
  23. data = data?{success:1,data:data}:{success:0};
  24. res.writeHead(200, {'Content-Type': 'text/json'});
  25. res.write(JSON.stringify(data));
  26. res.end();
  27. }
  28. }
  29. module.exports=Handler;