Reputation: 437
I have this function, I want it to be working with my view, how could I do it ?
def PlaySound(self):
while(True):
if GPIO.input(Snare) == False:
os.system("path/to/the/sound")
return ("Is activated")
def view(request):
return render(request, "page.html")
Upvotes: 0
Views: 194
Reputation: 308779
If PlaySound
is not a method of a class, then you don't need self
. use def PlaySound():
.
def PlaySound():
...
You can then call the method in the view, before you return the response.
def view(request):
PlaySound()
return render(request, "page.html")
Upvotes: 1