forked from shy2850/node-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfavicon.ico.js
More file actions
24 lines (23 loc) · 765 Bytes
/
Copy pathfavicon.ico.js
File metadata and controls
24 lines (23 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"use strict";
var path = require('path'),
mime = require('mime'),
fs = require('fs');
var favicon = path.join( __dirname , "/../../static/img/favicon.ico" );
exports.execute = function(req, resp){
console.log( "call for favicon.ico" );
fs.readFile(favicon, function (err, data){
if(err){
resp.writeHead(404, {"Content-Type": mime.get("html")});
resp.end("no favicon.ico");
}else{
var expires = new Date();
expires.setFullYear( expires.getFullYear() + 1 );
resp.writeHead(200, {
"Content-Type": mime.get("ico"),
"Cache-Control": "max-age=",
"Expires": expires
});
resp.end(data);
}
});
};