padelt / temper-python

libusb/PyUSB-based driver to read TEMPer USB HID devices (USB ID 0c45:7401) and serve as a NetSNMP passpersist module
Other
182 stars 76 forks source link

Add an HTTP server that outputs the same as the CLI interface #96

Closed daviessm closed 3 weeks ago

daviessm commented 4 years ago

This pull request contains an HTTP server called httpserver.py which acts exactly like cli.py but will serve HTTP requests on a specified port and respond with the current data. It holds a connection to any USB devices rather than re-opening them each time.

rdica commented 4 years ago

@daviessm Just curious, would using the http server block cli access, is this a one or the other choice? Thanks

daviessm commented 4 years ago

@rdica It's one or the other. The HTTP server will take a connection to the device(s) and hold on to them.

The reason for this is that in my setup the devices regularly fall off the bus if more than one application tries to access them at once: I can now push them all through the single HTTP server.

StatusCode404 commented 3 years ago

If you don't want exclusive use, then invoke the cli command from within a python program with a http server of some flavour.

I've been doing exactly that for the last 5 years using a flask microservice for temper USBs all around the place.

davet2001 commented 2 years ago

My feeling on this is that webserver functionality should be separate.

Since this is package is available on pypi, it can be imported and used however someone wants, potentially as a new project temper-python-webserver.

I think there are many people who will use this and don't want a webserver. Why give all those people the overhead/security risks?

padelt commented 2 years ago

I agree with @davet2001 .

padelt commented 3 weeks ago

I'll go ahead and close the pull request. If anyone has new thoughts on the matter, feel free to bring them up!