fix: add Dockerfile, starter

This commit is contained in:
Leifer Mendez
2023-01-08 16:47:28 +01:00
parent 5e6077dd8f
commit 4e0d33c6bb
32 changed files with 1164 additions and 164 deletions

View File

@@ -1,6 +1,6 @@
var http = require('http')
var fs = require('fs')
var path = require('path')
const http = require('http')
const fs = require('fs')
const path = require('path')
const PORT = process.env.PORT || 3000
@@ -8,23 +8,27 @@ const PORT = process.env.PORT || 3000
* Levantar un HTTP Server
*/
http.createServer(function (req, res) {
var cssPath = undefined
var fileStream = undefined
var imagePath = undefined
if (req.url === '/') {
fs.readFile('./public/index.html', 'UTF-8', function (err, html) {
res.writeHead(200, { 'Content-Type': 'text/html' })
res.end(html)
})
} else if (req.url.match('.css$')) {
var cssPath = path.join(__dirname, 'public', req.url)
var fileStream = fs.createReadStream(cssPath, 'UTF-8')
cssPath = path.join(__dirname, 'public', req.url)
fileStream = fs.createReadStream(cssPath, 'UTF-8')
res.writeHead(200, { 'Content-Type': 'text/css' })
fileStream.pipe(res)
} else if (req.url.match('.png$')) {
var imagePath = path.join(__dirname, req.url)
var fileStream = fs.createReadStream(imagePath)
imagePath = path.join(__dirname, req.url)
fileStream = fs.createReadStream(imagePath)
res.writeHead(200, { 'Content-Type': 'image/png' })
fileStream.pipe(res)
} else {
res.writeHead(404, { 'Content-Type': 'text/html' })
res.end('No Page Found')
}
}).listen(PORT, () => console.log(`Ready HTTP http://localhost:${PORT}`))
}).listen(PORT, () => console.log(`Escanear QR Code http://localhost:${PORT}`))