-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
50 lines (46 loc) · 1.43 KB
/
server.js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
var http = require("http"),
url = require("url"),
levelup = require("levelup"),
port = 80;
var spaceInfo = {
api: "0.12",
space: "HSBNE",
logo: "http://hsbne.org/assets/img/headerlogo.png",
icon: {
open: "http://hsbne.org/assets/img/headerlogo.png",
closed: "http://hsbne.org/assets/img/headerlogo.png"
},
url: "http://hsbne.org/",
address: "217 Macarthur Avenue, Eagle Farm QLD 4009",
contact: {
email: "[email protected]",
irc: "irc://freenode/hsbne",
ml: "[email protected]",
twitter: "@HSBNE"
},
lat: -27.45493,
lon: 153.050181,
open: false,
status: "closed",
lastchange: 1386524299
cache: {
schedule: "d.01"
}
};
var spaceJson = JSON.stringify(spaceInfo);
http.createServer(function(request,response){
var path = url.parse(request.url).pathname;
if (path === "/json") {
response.writehead(200, {"Access-Control-Allow-Origin": "*"});
response.writehead(200, {"Cache-Control": "no-cache")};
response.writeHead(200, {"Content-Type": "application/json"});
response.write(spaceJson);
response.end();
}
else {
response.writeHead(404, { "Content-Type": "text/plain" });
response.write("go to /json you dummy\n");
response.end();
}
}).listen(port);
console.log("Server Running on " + port);