🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Hosting a simple HTML with M5* device img src problem

    PROJECTS
    3
    7
    11.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      Thrasher
      last edited by

      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

      ajb2k3A 1 Reply Last reply Reply Quote 0
      • ajb2k3A
        ajb2k3 @Thrasher
        last edited by

        @thrasher Images still need to be saved in a specific method. I think it's to do with how micropython handles images.

        UIFlow, so easy an adult can learn it!
        If I don't know it, be patient!
        I've ether not learned it or am too drunk to remember it!
        Author of the WIP UIFlow Handbook!
        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

        1 Reply Last reply Reply Quote 0
        • T
          Thrasher
          last edited by

          Do you know which method is this and how do I call those images after?

          ajb2k3A 1 Reply Last reply Reply Quote 0
          • R
            robalstona
            last edited by

            @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

            T 2 Replies Last reply Reply Quote 1
            • T
              Thrasher @robalstona
              last edited by

              @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

              1 Reply Last reply Reply Quote 0
              • ajb2k3A
                ajb2k3 @Thrasher
                last edited by ajb2k3

                @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. Thanks

                It is a limitation of micropython, I found the issue on the mainstream micropython as well.

                UIFlow, so easy an adult can learn it!
                If I don't know it, be patient!
                I've ether not learned it or am too drunk to remember it!
                Author of the WIP UIFlow Handbook!
                M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                1 Reply Last reply Reply Quote 0
                • T
                  Thrasher @robalstona
                  last edited by

                  @robalstona Thanks, I did a try and it worked! However, line of code I got went through my wall ^^
                  Thanks

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post