Created
March 28, 2024 09:24
-
-
Save QVGK/7c0e90b1fbee986d57eff7e95b6f6fa7 to your computer and use it in GitHub Desktop.
HD Example 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dependencies | |
const express = require("express"); | |
const wifi = require("node-wifi"); | |
// Config | |
const serverApp = express(); | |
wifi.init({ | |
iface: null, | |
}); | |
// Scan Internet Function | |
async function scanInternet() { | |
const foundNetworks = await wifi.scan().catch((err) => { | |
return []; | |
}); | |
const currentNetwork = await wifi.getCurrentConnections().catch((err) => { | |
return {}; | |
}); | |
return { networks: foundNetworks, currentnetwork: currentNetwork[0] }; | |
} | |
serverApp.get("/wifi", async (req, res) => { | |
const scannedNetworks = await scanInternet(); | |
res.json(scannedNetworks); | |
}); | |
// Listen | |
serverApp.listen(3001, () => { | |
console.log("Wifi Scanner listening on Port 3001."); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment