-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
51 lines (44 loc) · 1.61 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
51
var http = require("http"),
fs = require("fs");
// languages
var langs = {};
langs.australian = require("./langs/australian");
langs.english = require("./langs/english");
langs.russian = require("./langs/russian");
langs.polish = require("./langs/polish");
langs.arabic = require("./langs/arabic");
langs.vietnamese = require("./langs/vietnamese");
langs.danish = require("./langs/danish");
langs.spanish = require("./langs/spanish");
langs.japanese = require("./langs/japanese");
langs.french = require("./langs/french");
langs.croatian = require("./langs/croatian");
langs.german = require("./langs/german");
langs.swedish = require("./langs/swedish");
langs.romanian = require("./langs/romanian");
langs.quenya = require("./langs/quenya");
langs.serbian = require("./langs/serbian");
langs.korean = require("./langs/korean");
langs.klingon = require("./langs/klingon");
langs.hindi = require("./langs/hindi");
langs.italian = require("./langs/italian");
langs.bulgarian = require("./langs/bulgarian");
langs.mandarin = require("./langs/mandarin");
http.createServer(function(request, response) {
var lang = request.url.substr(1);
// handle hello world by language, if present
if (typeof(langs[lang])!=="undefined")
{
langs[lang].handle(request, response);
}
// list and link all languages based on langs object
else
{
response.writeHead(200, {"Content-Type": "text/html"});
response.write("<html><body>Hello World in \n");
for (l in langs) response.write("<a href='"+l+"'>"+l+"</a> ");
response.write("</body></html>\n");
response.end();
}
}).listen(1234);
console.log("Server running at http://localhost:1234/");