-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathpingserver.js
More file actions
31 lines (29 loc) · 928 Bytes
/
pingserver.js
File metadata and controls
31 lines (29 loc) · 928 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
25
26
27
28
29
30
31
/* This script handles requests that come into ping.1999.io
It maintains a JSON file in the same directory as the script that counts updates
for each RSS file maintained by each of the participating 1999 servers.
It's designed to be run by the PagePark web server, but could be modified to be run
in any web server that can run JS scripts.
4/4/16; 10:45:25 AM by DW
*/
var urlFeed = parsedUrl.query.urlFeed;
if (urlFeed !== undefined) {
var now = new Date (), fname = "domains/ping.1999.io/pingers.json";
fs.readFile (fname, function (err, data) {
var jstruct = new Object ();
if (!err) {
jstruct = JSON.parse (data.toString ());
}
if (jstruct [urlFeed] === undefined) {
jstruct [urlFeed] = {
ct: 1,
when: now
}
}
else {
jstruct [urlFeed].ct++;
jstruct [urlFeed].when = now
}
fs.writeFile (fname, JSON.stringify (jstruct, undefined, 4));
});
}
"Thanks for the ping!";