Web server inside an Electron app?


#1

We’re developing a solution to read data from USB devices and expose the data read from USB devices to a third party web app running in a browser.

The solution I’ve planned so far is like this:

  1. We develop an Electron desktop app, which is installed on customer end user workstations and can read the data from USB devices. As far as I checked, there are node libraries for accessing USB devices and they work pretty fine.

  2. The Electron desktop app has a built in web server which is running on some port X.

  3. We provide a standard web based JS library which connects to the web server running inside the electron app on the local machine on port X. I believe there are no limits for JS to do a standard GET request to a http://localhost:X/get-my-data/

  4. The user prepares the USB device (probably ticks some buttons on the Electron desktop app) and gets the data from the USB device seamlessly in their web application.

Does it sound reasonable or is there a better solution in providing a seamless integration of data obtained from USB devices into a web application?

I’ve looked into Chrome native API for accessing USB devices, however, I run into some permission issues on my Mac and it looks like they are removing it in some not so distant future.


#2

hey Ingus,

I have faced the same problem with you recently, and I am confused on step 2, have you finished your project?


#3

Not sure if this is the best way, but here’s something I found on the topic. Hope it’s helpful https://github.com/frankhale/electron-with-express


#4

This seems to be working. Here’s some more detail