by Corey Faulkerson
Posted on 2016-10-21 01:48:06
play a music file directly on a server when a url is loaded using php and python.
<?php
echo shell_exec("sudo python /var/www/html/cha.py");
?>
pyton file called cha.py
#script
print('hello world1')
import subprocess
subprocess.call(['aplay -fdat /var/www/html/sounds/chaching.wav'], shell=True)
print('hello world2')
need to chmod python script
chmod 777 /var/www/html/cha.py
and it should play the sound when you load the php file.
Back