-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequestHandler.js
More file actions
38 lines (31 loc) · 868 Bytes
/
requestHandler.js
File metadata and controls
38 lines (31 loc) · 868 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
26
27
28
29
30
31
32
33
34
35
36
37
var querystring = require("querystring");
//Handler of request to /
function home(response){
console.log('Handler to / ');
var body = '<html>'+
'<head>'+
'<meta http-equiv="Content-Type" content="text/html" charset="UTF-8" />'+
'</head>'+
'<body>'+
'<form action="/data" method="post">'+
'<textarea name="text" rows="20" cols="60"></textarea>'+
'<input type="submit" value="Enviar texto" />'+
'</form>'+
'</body>'+
'</html>';
response.writeHead(200, {"Content-Type": "text/html"});
response.write(body);
response.end();
}
/*
Function to send data of test
response [] : object to return
*/
function data(response){
var data = "estos son los datos ";
response.writeHead(200, {"Content-Type": "text/html"});
response.write(data);
response.end();
}
exports.home = home;
exports.data = data;