I am trying to pass a URL to a variable in python (youtube url of the video to be played on the Raspberry Pi), but somewhere along the way the forward slash character is being interpreted as an end of the string/variable. So instead of getting "http://www.youtube.com/watch?v=5NV6Rdv1a3I", I get "http:".
I am using the WebIOPi server to display a webpage in html that contains a textarea. When I click a button on the webpage, the function sendLink() is called and the text from the textarea passed as an argument.
Content of index.html:
function sendLink() {
var text = $('textarea#videolink').text();
webiopi().callMacro("playVideo", text);
}
...
<textarea rows="1" cols="30" id="videolink">Enter YouTube link here</textarea>
The function callMacro calls a macro named playVideo, written in another script in python:
@webiopi.macro
def playVideo(text):
print (text)
webiopi.debug(text)
When I enter "a/b/c" into the textarea and click the button, only "a" is displayed by print and webiopi.debug, even though the general debug information that is displayed along with it says "POST /macros/playVideo/a/b/c HTTP/1.1" 200, which I believe means that the variable is being passed to the function correctly.
(Idea for sending text entered into the textarea taken form here: http://timcorrigan.com/raspberry-pi-tracked-robot-streaming-video-and-text-to-speech/)
How do I solve this? Any solution is appreciated.
I solved the problem. While kalhartt's answer did not completely apply to my problem, this part got me thinking:
As I wrote in my original question, WebIOPi calls macros like this
where "playVideo" is the macro that is being called and anything here
is an argument to be passed to the macro. The argument is only up to the forward slash after it, because after that slash there are no more categories (you used one slash to say you were going to call a macro, another slash to say the name of the macro, the third slash to pass arguments, and the fourth one for... what?).
This is why anything after a forward slash was being cut off. I solved the issue by replacing all forward slashes in javascript with
and then replacing "fslash" with "/" in the python script that was supposed to receive the argument. I also replaced question marks, since those were causing problems as well.