1.0.0 • Published 7 years ago

get-favicon v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

Get Favicon

Simple Node.js favicon server

Install

npm install get-favicon --save

Usage

var http = require('http');
http.createServer(function(req, res){
    
    if (req.url == '/favicon.ico') {
        require('get-favicon').favicon(res);
    }
    
}).listen(8080);

Parameters

The module has one mandatory parameter, which is the http response object But you can also specify the path to your favicon file (if it's not set, It'll look for it in the root directory) You can pass also function to execute if the file wasn't found. If not, we'll show a blank 404 page in plain text format.

Examples:

//define path and error callback
require('get-favicon').favicon(res, './public/favicon.ico', function(err){
    res.end();
});

//define just error callback
require('get-favicon').favicon(res, function(err){
    res.end();
});
1.0.0

7 years ago