-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp-old.js
31 lines (23 loc) · 951 Bytes
/
app-old.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
// Web Server
// Puedes probarlo entrando a localhost:8080
const http = require('http');
http.createServer((request, response) => {
// console.log(request);
const persona = {
id: 1,
nombre: 'Alexis Rojas'
}
// response.setHeader('Content-Disposition', 'attachment; filename=lista.csv');
// Permite enviar codigos de respuesta y el tipo de contenido
// response.writeHead(200, {'Content-Type': 'application/json'});
// response.writeHead(200, {'Content-Type': 'application/csv'});
// response.writeHead(200, {'Content-Type': 'text/plain'});
// Imprime un mensaje en pantalla, en el navegador web
// response.write(JSON.stringify(persona));
// response.write('Id \n');
// response.write('Nombre \n');
// Indicamos la finalizacion de la respuesta
response.write('Hola Mundo')
response.end();
}).listen(8080);
console.log('Escuchando el puerto', 8080);