How can I give www-data permissions to run a .sh script with sudo from an index.php?

I have a script in /var/www/Web-EvilBlock/ejecuta_py.sh

What that script does is run a .py file ( sudo python3 /var/www/Web-Evilblock/EvilBlock.py )
(From what I saw, there are problems trying to run a .py from php, so I made a .sh file that will run that .py)

My problem is that from my web page in php, I have a button that executes that bash script, but it doesn’t work.(Need sudo permissions)

The only way I’ve gotten it to work is in visudo by adding the line:
www-data ALL=(ALL) NOPASSWD: ALL
But I would like to make it a little more secure. Is there any other way? I am new to linux.

www-data is the owner of /var/www/Web-EvilBlock and have execution permission