Hosting a simple HTML with M5* device img src problem
-
Hello!
As part of my huge "Get rid of arduino!" campaign, I'm trying to implent some projects with M5Stack using raw micropython.
I'm trying to use M5Stack (grey one) as webserver hosting a simple HTML page with couple of input fields and button to acquire data from user.
I did a real simple HTML page but it has a small image - logotype (jpg) which I would like to see in browser. I'm not dealing with M5Stack's TFT at the moment.
Problem is, no matter how hard I'm trying, I can't dispay image.
I'm using VS Code to upload image inside res folder and then perform <img src="res/logo.jpg></img> but nothing happens.
If I perform same on PC (windows) everything works as intended.
Complete html code is sent as string and put between ' ' ' and ' ' 'I tried to upload image to other places, like root of fs or other folders - still no effect.
Maybe someone faced common issue?
Thanks -
@thrasher Images still need to be saved in a specific method. I think it's to do with how micropython handles images.
-
Do you know which method is this and how do I call those images after?
-
@thrasher as you say you did simple web server. If you want implement send images you must handle image receive
request. Analogically to send your web page from string or text file you must send raw binary data from file. If image is small you could be try convert it to text in BASE64 format and insert it into <img src="data:image/jpg..........">online converter
https://www.base64-image.de/encode -
@robalstona thanks, I will try with base64..
However, my html is sent as string and works as intended. As far as I understood, browser simply cant get access to my image on m5device. Thought there's a way to forward route for it. Thanks -
@thrasher said in Hosting a simple HTML with M5* device img src problem:
Do you know which method is this and how do I call those images after?
Sorry for the time delay, I have written a guide on how to same images in my WIP book that you can read here http://ajbryant.co.uk/UIFLOW/quickblockref.pdf
@thrasher said in Hosting a simple HTML with M5* device img src problem:
@robalstona thanks, I will try with base64..
However, my html is sent as string and works as intended. As far as I understood, browser simply cant get access to my image on m5device. Thought there's a way to forward route for it. ThanksIt is a limitation of micropython, I found the issue on the mainstream micropython as well.
-
@robalstona Thanks, I did a try and it worked! However, line of code I got went through my wall ^^
Thanks