[AWS] html : <img ...> doesn't find the image
Jeremy Piffret
j.piffret at gmail.com
Thu Mar 19 23:18:22 CET 2009
sry, I send the response only to Pascal Obry ...
(first time I use a mailing list, I need some time to adapt)
Thanks for your answer
Pascal Obry a écrit :
> Hi Jeremy,
>
>
>> with Ada.Text_IO;
>> with Ada.Integer_Text_IO;
>>
>> with AWS.Response;
>> with AWS.Server;
>> with AWS.Status;
>>
>> procedure Test is
>>
>> WS : AWS.Server.HTTP;
>>
>> function Main_CB (Request : in AWS.Status.Data)
>> return AWS.Response.Data
>> is
>> URI : constant String := AWS.Status.URI (Request);
>>
>> begin
>> return AWS.Response.Build ("text/html", "<img src=aws.png>");
>>
>
> First you need quote here:
>
> return AWS.Response.Build ("text/html", "<img src=""aws.png"">");
>
Quote didn't change anything, but thanks : I didn't remind how to put a
quote in a string :)
>> end Main_CB; -- or src=/aws.png
>>
>
> Then the question is who's going to serve your aws.png? The callback
> procedure you have here respond only "<img ...>".
>
> What happens is:
>
> - you connect to your server
> - whatever the URL passed you always get "<img src...>"
> - the Web browser sees a reference to an image
> - It sends back another request to the server to get the
> image content
> - the server send back "<img src=...>" for the image content
>
> This is not what you meant to do :) No magic !
>
It's so clear when it's said like this :)
> You need to either test for URI = "aws.png" and respond using
> AWS.Response.File constructor.
>
I tried something like this once, but it didn't work. I think I made an
error.
> Another solution (which scale better) is to place all images inside a
> directory say img and create a dispatcher that will get called for each
> URI whose prefix is "/img". Then you main page should look like this:
>
> return AWS.Response.Build
> ("text/html", "<img src=""/img/aws.png"">");
>
> All this is described into the AWS User's Guide.
>
Yup, I read it several times.
> Another comment - I understand that this is probably a test - you should
> consider using the template engine and never embed any HTML into your code.
>
Indeed, it was just an example to reproduce the same error.
> Pascal.
>
>
Thanks, it's working now.
More information about the AWS
mailing list