-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGroupInterface.js
More file actions
49 lines (36 loc) · 1.27 KB
/
GroupInterface.js
File metadata and controls
49 lines (36 loc) · 1.27 KB
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
var http = require('http'),
util = require('util'),
fs = require('fs'),
url = require('url'),
qs = require('querystring');
var XtensGroup = require('./XtensGroup.js');
var XtensGroupDao = require('./XtensGroupDao.js');
var groupDao = new XtensGroupDao();
var server = http.createServer(function (req,res){
var url_parts = url.parse(req.url,true);
var body = '';
if(req.method === 'POST'){
console.log('Request found with POST method');
req.on('data', function (data) {
body += data;
console.log('got data:'+data);
});
req.on('end', function () {
var POST = qs.parse(body);
var group = new XtensGroup(POST.id,POST.name);
groupDao.create(group);
res.end("You created a new Group!");
});
} else {
req.on('data',function(data){ res.end(' data event: '+data);});
if(url_parts.pathname == '/')
fs.readFile('./Group.html',function(error,data){
res.end(data);
});
else if(url_parts.pathname == '/getGroup'){
console.log('Serving the Got Data.');
}
}
});
server.listen(8080);
console.log('Server listenning at localhost:8080');