Git Product home page Git Product logo

Comments (3)

friedrith avatar friedrith commented on June 3, 2024 1

Hi,

Can you format your code using code balise in markdown.

Node-wifi is not meant to be used on server since most of the time servers don't have any wifi card. And you cannot used node-wifi in the broswer since it uses child-process from node api.

from node-wifi.

weiwanghasbeenused avatar weiwanghasbeenused commented on June 3, 2024

I see...I guess I need to find another library. Thank you though!

Sorry about the messy code. Here's the formatted one if you're interested. Some CS student helped me with it so I'm not 100% sure about how it works.

var express = require('express');
var app = express();
var wifi = require('node-wifi');
var parsedNetworks;
var cors = require('cors');
var ip = require('ip');
var myIP = ip.address();
var https = require('https');
var path = require('path');
var fs = require('fs');
 
console.log(myIP); 
app.use(cors())

/*wifi*/
wifi.init({
	iface :null
});
wifi.scan(function(err, networks){
	if(err){
		console.log(err);
	}else{
		// pushing data to array "parsedNetworks"
		parsedNetworks = [];
		networks.forEach(function(e){
			parsedNetworks.push({'ssid': e.ssid, 'signal_level':e.signal_level, 'mac':e.mac, 'security':e.security})
		})
		// consoling ssid of each signal
	  	for(i=0;i<networks.length;i++){
	  	  console.log(networks[i].ssid);
	  	}
	}
});
// sending wifi data at url/getwifis
app.get('/getwifis', function (req, res) {
   res.json(parsedNetworks);
})

// setting up https server
var certOptions = {
  key: fs.readFileSync(path.resolve('server.key')),
  cert: fs.readFileSync(path.resolve('server.crt'))
}

var server = https.createServer(certOptions, app).listen(8081,function () {
   var host = server.address().address
   var port = server.address().port
   console.log("Example app listening at https://%s:%s", host, port)
})

from node-wifi.

lock avatar lock commented on June 3, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from node-wifi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.