Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Aug 29, 2014 13:46:32 GMT -8
I am trying to display a .png file through the Remote Webview window, but I must not be understanding how to put the correct address into the code, because the text all shows up, but for the image, all that shows up is a little square where the image should appear.
This is the code I am using in Local.py:
# W-11 Test
elif (objectServerID == "W-11"):
# Check for validate request.
if (validate == "Yes"):
outgoingXMLData += Validate.buildValidateResponse("YES")
outgoingXMLData += BuildResponse.buildFooter()
return outgoingXMLData
# Build the HTML page.
responseData = "<html><head>"
responseData += "</head>"
responseData += "<body>"
responseData += "<h1>Temperature Data</h1>"
responseData += '<img src="/home/pi/Desktop/Temp_29-Aug-2014.png"/>'
responseData += '<h1>Hello</h1>'
responseData += "</body></html>"
outgoingXMLData += BuildResponse.buildResponse(responseData)
outgoingXMLData += BuildResponse.buildFooter()
return outgoingXMLData
The name of the image is Temp_29-Aug-2014.png. Like I mentioned, both the headers "Temperature Data" and "Hello" show up, and between them is simply a small box.
|
|
|
Post by SDL on Aug 30, 2014 12:49:53 GMT -8
Tays,
The webserver will only display images in the "static " directory. Try putting your image there.
Best regards,
BP
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Sept 4, 2014 12:21:37 GMT -8
I have now moved the image file to the static directory, and I modified the HTML code to look like this:
responseData += '<img src="/home/pi/RasPiConnectServer/static/Temp_29-Aug-2014.png" alt="graph">'
All that shows up is still a box, but this time it has the alternate image name ("graph") that I included in the HTML. Is there some special way to reference the address of the image so RasPiConnect knows where to find it on my Raspberry Pi?
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Sept 4, 2014 12:47:08 GMT -8
Never mind, I was able to figure it out. For anyone else who may need the answer to this, the code that finally worked was:
LOCALURL = "http://ip_address_of_raspberry_pi:9600/" responseData += '<img src="' + LOCALURL + 'static/Temp_29-Aug-2014.png" alt="graph">'
|
|