Get url of image present in glitch directory

I’m trying to save images in “bin” folder using python file library. The upload process to “bin” folder is successful, and the image (i1588240674591.jpg) is visible, but when I try to set “src” of an image tag as “./public/bin/ixxxxxxxxxxxx.jpg”, then it shows that the link is broken/invalid.

I just want to have the link for images I generate dynamically in “bin” folder. It works perfectly on localhost. Any workaround?

Also, I know, glitch provides an “assets” option. But, I want to get the link to image programmaticlly, any ideas?

BTW, my experience with glitch is most helpful so far, in deploying websites :wink:

The whole process
Okay, I’m prompting client to upload image, then I request server to store the imageurldata (like data:image/png;base64…) in a newly created jpg file, named as “i1588240674591.jpg” in our particular case. Then, when the server sends the response, JS confirms that image have been stored and it adds an image tag to document as <img src="./i1588240674591.jpg">.

Try removing the ./

I think I was unclear a bit. Okay, I’m prompting client to upload image, then I request server to store the imageurldata (like data:image/png;base64…) in a newly created jpg file, named as “i1588240674591.jpg” in our particular case. Then, when the server sends the response, JS confirms that image have been stored and it adds an image tag to document as . Now, you’ve suggested to remove “./”, which I think will make it absolute address? Isn’t it?
I’ve also added a comment in app :wink:

Edit: I’ve commented a pointer where the image’s final link is generated in server.py

:+1:

Hey @vrintle! I’m not a Python programmer but in looking at your project, you should be able to access the /public directory from the root of the rv-blog.glitch.me site, e.g., https://rv-blog.glitch.me/bin/i1588240674591.png — so the img src would be /bin/i1588240674591.png.

1 Like

@angelo thanks man!! :smile:
Now, everything is working fine. btw, i couldn’t clearly understand what happens on removing “public”.

1 Like

That’s great! This topic is a bit more about coding than Glitch (it can be hard to tell what the issue is sometimes!), so I’m going to move it to the coding help section of the forums in case any more questions come up. :slight_smile: