Skip to content

Instantly share code, notes, and snippets.

@QVGK
Created March 28, 2024 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save QVGK/7c0e90b1fbee986d57eff7e95b6f6fa7 to your computer and use it in GitHub Desktop.
Save QVGK/7c0e90b1fbee986d57eff7e95b6f6fa7 to your computer and use it in GitHub Desktop.
HD Example 1
// 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