Select Git revision
view-in-view.mp4
cf.js 1.70 KiB
// new year new bootstrap
const express = require('express')
const app = express()
// will use these to figure where tf we are
const os = require('os')
let ifaces = os.networkInterfaces()
// serve everything: https://expressjs.com/en/resources/middleware/serve-static.html
app.use(express.static(__dirname))
// if these don't exist, they get 'nexted' to any other 'middleware' we write
app.get('/hunklist', (req, res) => {
// we would fs/ through our list, and serve that,
res.send('the-false-file-list')
})
// we also handle file-saving this way,
app.put('/save/systems/:file', (req, res) => {
console.log('put req to ' + req.params.file)
})
let port = 8080
// and listen,
app.listen(port)
// want to announce our existence,
Object.keys(ifaces).forEach(function(ifname) {
var alias = 0;
ifaces[ifname].forEach(function(iface) {
if ('IPv4' !== iface.family){//} || iface.internal !== false) {
// skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
return;
}
if (alias >= 1) {
console.log('cf available on: \t' /*ifname + ':' + alias,*/ + iface.address + `:${port}`);
// this single interface has multiple ipv4 addresses
// console.log('serving at: ' ifname + ':' + alias + iface.address + `:${port}`);
} else {
console.log('cf available on:\t' /*ifname + ':' + alias,*/ + iface.address + `:${port}`);
// this interface has only one ipv4 adress
//console.log(ifname, iface.address);
}
++alias;
});
});
/*
let begin = () => {
// setup to dish files,
ex.get('/', (req, res) => {
console.log('req /')
res.sendFile(__dirname + '/index.html')
})
http.listen(8080, () => {
console.log("is listening on 8080")
})
}
begin()
*/