links-page/index.js
2023-10-05 07:36:16 -04:00

27 lines
860 B
JavaScript

const { readFile } = require('fs/promises')
const { Server } = require('http')
async function main() {
const webPage = await readFile('index.html', { encoding: 'utf-8' })
const pfp = await readFile('pfp.png')
const favicon = await readFile('favicon.ico')
const server = new Server(
(req, res) => {
if (req.url === '/pfp.png')
res.writeHead(200, { 'Content-Type': 'image/png' })
.end(pfp)
else if (req.url === '/favicon.ico')
res.writeHead(200, { 'Content-Type': 'image/vnd.microsoft.icon' })
.end(favicon)
else
res.writeHead(200, { 'Content-Type': 'text/html' })
.end(webPage)
}
)
server.listen(1312, () => {
console.log('listening on 0.0.0.0:1312')
})
}
main()