Add 'counterServer.js'

This commit is contained in:
mattx 2020-09-03 16:56:07 +00:00
parent f2925482cd
commit a1590bae4f
1 changed files with 13 additions and 0 deletions

13
counterServer.js Normal file
View File

@ -0,0 +1,13 @@
// Embeddable counter
const text2png = require("text2png");
const http = require("http");
const port = 51000;
var counter = 0;
const server = http.createServer((req,res) => {
res.writeHead(200,{"Content-Type":"image/png"});
if (!req.headers["referer"]){res.end(text2png("frog"));return;}
if (req.headers["referer"].includes("frogs")) counter++;
res.end(text2png(String(counter)));
});
server.listen(port);