Display a random image with vibe.d

jfondren julian.fondren at gmail.com
Sun Jun 20 13:06:20 UTC 2021


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.



More information about the Digitalmars-d-learn mailing list