How to use a python package with sudo privileges inside Flask? How to use a python package with sudo privileges inside Flask? flask flask

How to use a python package with sudo privileges inside Flask?


I believe the package will be trying to access the device /dev/gpiomem (possibly (/dev/gpiochip0 or /dev/gpiochip1).

I think the neatest way to address this would be have those devices be owned by a group other than root and give that group permission to access the device, e.g.

sudo sugroupadd gpiochgrp gpio /dev/gpio*chmod g+rw /dev/gpio*

Then I'd go ahead and add your user to that group (by default this is ubuntu, but you may have created another user):

usermod -a -G gpio ubuntu

Now you've created a group called "gpio" that now has permissions to access your Pi's GPIO, and added your user to that group.

Please note, I have not tested this