Skip to content

Commit

Permalink
adds .png image so we can include a test image in email. nelsonic/ide…
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Jan 22, 2016
1 parent 9ababb0 commit ff92bf7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
Binary file added image_50x50.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 24 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ var http = require('http');
var hits = require('./lib/hits');
var port = process.env.PORT || 8000;
var wreck = require('wreck');

var fs = require('fs');
var png = fs.readFileSync('./image_50x50.png');
http.createServer(function handler(req, res) {
var url = req.url;
var agent = req.headers.user-agent
var r = req.headers;
r.ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
r.url = url.replace('.svg', '');

r.url = url.replace('.svg', '').replace('.png', '');
console.log('>>'+url);
if (url.match(/svg/)) {
hits.add(r, function(err, count) {
console.log(r.url, ' >> ', count)
console.log(r.url, ' >> ', count);
var newurl = "https://img.shields.io/badge/hits-" + count +"-brightgreen.svg"
wreck.get(newurl, function (error, response, html) {
// expiry headers see: http://stackoverflow.com/a/2068407/1148249
Expand All @@ -28,6 +29,25 @@ http.createServer(function handler(req, res) {
});
})

}
else if (url.match(/png/)) {
hits.add(r, function(err, count) {
console.log(r.url, ' >> ', count)
// var newurl = "https://img.shields.io/badge/hits-" + count +"-brightgreen.png"
// wreck.get(newurl, function (error, response, html) {
// expiry headers see: http://stackoverflow.com/a/2068407/1148249
// console.og()
var head = {
"Cache-Control": "no-cache, no-store, must-revalidate", // HTTP 1.1
"Pragma": "no-cache", // HTTP 1.0
"Expires": "0", // Proxies
"Content-Type":"image/png"
}
res.writeHead(200, head);
res.end(png);
// });
})

}
else if(url === '/favicon.ico') {
var fav = 'https://www.google.com/images/google_favicon_128.png'
Expand Down

0 comments on commit ff92bf7

Please sign in to comment.