Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion clase-2/1.http.js
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -9,7 +10,8 @@ const processRequest = (req, res) => {
if (req.url === '/') {
res.end('<h1>Mi página</h1>')
} 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('<h1>500 Internal Server Error</h1>')
Expand Down