Display a random image with vibe.d
vnr
cfcr at gmail.com
Sun Jun 20 13:58:22 UTC 2021
On Sunday, 20 June 2021 at 13:06:20 UTC, jfondren wrote:
> On Sunday, 20 June 2021 at 12:34:33 UTC, vnr wrote:
>> I don't understand why the image doesn't display, when I take
>> an image from the internet and give the url, it works fine
>> though.
>
> ```
> $ curl -s http://127.0.0.1:8080/|grep img
> <img src="images/rndimg/img2.jpg"/>
> ```
>
> This is a relative URL, so to satisfy it the browser will tack
> it onto
> the end of the current request, making a request like the
> following:
>
> ```
> $ curl -s http://127.0.0.1:8080/images/rndimg/img2.jpg|grep img
> <img src="images/rndimg/img2.jpg"/>
> ```
>
> ... which is answered, not with an image, but with the
> random-image
> page. Your webserver needs to serve images if it's going to be
> asking
> visitors to ask it for images. Right now your webserver *only*
> tells
> visitors to ask it for images.
>
> Your webserver will also always recommend the same image.
Thanks for the answers, I understand better what is going on.
So, what should I do to make my server respond with a random
image, and not the random image page? I'm fairly new to vibe.d,
so I don't yet know the intricacies of how to handle this style
of thing and I couldn't find how to do it in the documentation.
Thank you.
More information about the Digitalmars-d-learn
mailing list