forked from garann/node-for-frontend-devs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path05-02.js
More file actions
25 lines (21 loc) · 696 Bytes
/
05-02.js
File metadata and controls
25 lines (21 loc) · 696 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
var http = require("http"),
querystring = require("querystring"),
redis = require("redis"),
db = redis.createClient(6379, "127.0.0.1");
//db.hset("users", "Jaime", "Developer", function(){});
http.createServer(function(req, res) {
var qs = querystring.parse(req.url.split("?")[1]),
firstName = qs.firstName,
userName,
page;
db.hget("users", firstName, function(err, value) {
if (err) {
throw err;
}
userName = firstName + " " + value;
html = "<!doctype html>" +
"<html><head><title>Hello " + userName + "</title></head>" +
"<body><h1>Hello, " + userName + "!</h1></body></html>";
res.end(html);
});
}).listen(8000);