https post

This commit is contained in:
barwie2@st.amu.edu.pl 2020-03-09 22:58:57 +01:00
parent 414cceacb2
commit 6ab5679bde
1 changed files with 15 additions and 15 deletions

View File

@ -24,28 +24,28 @@ var server = http.createServer(function (request, response) {
});
request.on('end', function () {
try {
body = JSON.parse(body);
var send_array = {
"type": "data",
"id": body.student_index,
"name": body.student_name,
"surname": body.student_surname,
"classes_code": body.classes_code
};
lookup[body.classes_code].send(JSON.stringify(send_array));
response.end("Added");
} catch (e) {
console.log(e);
}
body = JSON.parse(body);
var send_array = {
"type": "data",
"id": body.student_index,
"name": body.student_name,
"surname": body.student_surname,
"classes_code": body.classes_code
};
lookup[body.classes_code].send(JSON.stringify(send_array));
response.end("Added");
});
}
else {
response.end("Undefined request .");
response.end("Undefined request.");
}
});
server.on('error', function (e) {
console.log(e);
});
var http_port = 8889;
server.listen(http_port);
console.log("HTTP server running on port " + http_port);