-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (31 loc) · 854 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var express = require('express');
var app = express();
var wifi = require('node-wifi');
var parsedNetworks;
var cors = require('cors');
app.use(cors());
app.listen(process.env.PORT || 8081);
wifi.init({
iface :null
});
wifi.scan(function(err, networks){
if(err){
console.log(err);
}else{
console.log(networks);
parsedNetworks = [];
networks.forEach(function(e){
parsedNetworks.push({'ssid': e.ssid, 'signal_level':e.signal_level, 'mac':e.mac, 'security':e.security})
})
console.log(parsedNetworks);
}
});
app.get('/getwifis', function (req, res) {
res.json(parsedNetworks);
// res.render('pagetest.html', {pn: parsedNetworks});
});
/*var server = app.listen(8081, function () {
var host = server.address().address
var port = server.address().port
console.log("Example app listening at http://%s:%s", host, port)
})*/