[Lazarus] httpWebServer does not show images for some users
Michael Van Canneyt
michael at freepascal.org
Sat Jul 7 18:06:06 CEST 2012
On Sat, 7 Jul 2012, John Repucci wrote:
>> Message: 2
>> Date: Sat, 7 Jul 2012 09:31:44 +0200 (CEST)
>> From: Michael Van Canneyt <michael at freepascal.org>
>> Subject: Re: [Lazarus] httpWebServer does not show images for some
>> users
>> To: Lazarus mailing list <lazarus at lists.lazarus.freepascal.org>
>> Message-ID: <alpine.DEB.2.00.1207070925320.11517 at home.telenet.be>
>> Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII
>>
>>
>>
>> On Fri, 6 Jul 2012, John Repucci wrote:
>>
>>> I've been playing around with the httpwebserver and having problems
>>> getting it to display images.
>>> see: http://www.lazarus.freepascal.org/index.php/topic,17296.0.html
>>> for some history on this.
>>>
>>> I've added the project if you care to look at it.
>>>
>>> Neither Reinier or I see the image when we compile the app, but
>>> Leledumbo does see the image.
>>
>> I also could see the image, but the URL I had to use is:
>>
>> http://localhost:8081/img/index.html
>>
>> The reason for this is that you have 2 modules in your application.
>>
>> If you do not specify a path, the webserver has no way of determining
>> what module it should invoke. There is a property 'AllowDefaultModule'
>> which will allow to select a default module if no module name is found.
>>
>> Then, if you have multiple modules, you need to tell the webserver which
>> is the default module to use. You can do this by setting DefaultModuleName.
>>
>> So, I set up the project file by adding
>>
>> Application.AllowDefaultModule:=True;
>> Application.DefaultModuleName:='img';
>>
>> before
>> Application.initialize;
>>
>> and then everything worked fine with the URL:
>>
>> http://localhost:8081/index.html
>>
>> Michael.
>
> Michael,
>
> After adding the above lines (thank you) and using
> http://localhost:8081/index.html, I get a blank page (and nothing on
> the source page). (tested using both FF and Chrome)
>
> The only way I am able to see the expected web page is by using:
> http://localhost:8081/main/default (still no image).
>
> When I use Application.DefaultModuleName:='main', then going to
> http://localhost:8081/ I see the expected page (still no image).
>
> re: Modules - I have two modules? I see the Main module (
> RegisterHTTPModule('Main', TMain)), but where is the 2nd module?
The file serving module is also a module.
It is 'hidden', as there is no visible data module for you to put components on,
but in the background there is a module nonetheless.
> 'img' is suppose to be the location for my image files. (in this
> case, in the same directory as the application)
Well, img is the location of all files, including the index.html file ?
Which is why I put it as the default module: it first serves the index.html
file (implicitly, because there is no path, and hence the default is used),
and then the img file (explicitly, since it's URL starts with /img/).
I used the sources you sent to the mailing list, which I expect to be the
same as you are using ?
I cannot do more than explain how it works :-)
Michael.
More information about the Lazarus
mailing list