Reputation: 1090
I want to be able to prompt users that visit our site to download our Electron app of it is not already. I basically just need a way to ping electron to see if the process is running. Ideally I'm just looking a specific file inside the Electron app would be great and then just access it via a port. Example, http://localhost:5580/doesExist.html
I've looked into express to see if I could package express with electron and just have electron run a separate express app, but I feel like this is way too complicated just to have an electron page accessible via URL.
Are there any other options?
So far the idea is to AJAX the URL I want to create above.. if it exists then don't prompt. If it does not exist... run our protocol to launch the application and then AJAX the URL again to see if it exists.. if it still does not, display the dialog to install the application.
Upvotes: 2
Views: 796
Reputation: 1090
Of course I find the solution almost immediately after this.
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('Hello World!');
res.end();
}).listen(8181);
})
Just replace Hello World!
with a JSON string showing the application is running.
Upvotes: 1