From cd1a72af69bf7a338a1d34697238096b37a4f7ed Mon Sep 17 00:00:00 2001 From: Juan Pasten Castillo Date: Wed, 24 Apr 2024 23:32:30 -0400 Subject: [PATCH] Modificado - Cambio para que la imagen funcione en windows, no solo mac --- clase-2/1.http.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clase-2/1.http.js b/clase-2/1.http.js index 5bc2ab3..ad3025f 100644 --- a/clase-2/1.http.js +++ b/clase-2/1.http.js @@ -1,5 +1,6 @@ const http = require('node:http') // protocolo HTTP const fs = require('node:fs') +const path = require('node:path') const desiredPort = process.env.PORT ?? 1234 @@ -9,7 +10,8 @@ const processRequest = (req, res) => { if (req.url === '/') { res.end('

Mi página

') } else if (req.url === '/imagen-super-bonita.png') { - fs.readFile('./placa.png', (err, data) => { + const thePath = path.join(__dirname, 'placa.png') + fs.readFile(thePath, (err, data) => { if (err) { res.statusCode = 500 res.end('

500 Internal Server Error

')