Cabbage Logo
Back to Cabbage Site

HTTP-Request with python in csound

I’d like to make a plugin which performs HTTP requests as soon as the host starts or stops recording. I figured out how to make it work inside Cabbage with that rather ugly code snippet shown below but as soon as I export this as an AU-Plugin it does not work inside the DAW.

Do you know another solution to perform HTTP requests inside csound?
Thank you for your help

pyinit
pyruni "import os"

;check if host is currently recording
if changed:k(kIsRecording)==1 then
	if kIsRecording == 1 then
	    pyruni {{data = '{"type":"output","value":true}'}}
	else
	    pyruni {{data = '{"type":"output","value":false}'}}
	endif
	pyruni {{os.popen("curl -X POST -H 'Content-Type: application/json' http://recordinglight.local:5000/api/gpio/io/12 -d '"+data+"'")}}
endif

That’s a neat solution, but I’m afraid I’ve no idea what it doesn’t work in a host. Did you try a VST version? Did you add a csoundoutput widget to see if Csound reports anything odd in its messages?