Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2019-02

CGI with datamodule does not work

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

AB

Hi Guys,

I have tried to update my old web project that is in maintenance mode since a few years now, using the latest stable Lazarus/FPC, and fcl-web just does not want to work (Tried Lazarus 1.8.4/FPC 3.0.4, Lazarus 2.0.0/FPC 3.0.4 with Apache 2.4, on Linux x86_64, though the OS should not matter with fcl-web).

So, after I could not make my original project work with the newer fcl-web, I have created a basic Lazarus project: File -> New -> CGI Application, and added a default action that just returns a simple html page:

procedure Tblahblah.WebDefaultActionRequest(Sender: TObject;
   ARequest: TRequest; AResponse: TResponse; var Handled: Boolean);
begin
   Handled := true;
   AResponse.Content := '<html><body>This function is not implemented
yet. ' + DateTimeToStr(Now) + '</body></html>';
end;

This one did not work either. Tried in docker with apache-alpine, docker with apache, heck, even put it on my live Ubuntu 16.04 with Apache web server at the end, with the same result, an error HTML page from the CGI application:
"The application encountered the following error:

Error: Not found
Stack trace:
$0000000000499B40
$00000000004990EF"

Did anyone test this fcl-web part lately?

BTW, A simple CGI application works OK (File -> New -> Custom CGI Application), though there are no Actions, of course:

Procedure TMyCGIHandler.HandleRequest(ARequest : Trequest; AResponse :
TResponse);
begin
   // Your code here
   AResponse.Content := '<html>Something. (' + ARequest.QueryString +
')</html>';
end;

Any reproduction or help is appreciated.

AB

Sven Barth
to AB
AB wrote 48 lines
Hi Guys, I have tried to update my old web project that is in maintenance mode since a few years now, using the latest stable Lazarus/FPC, and fcl-web just does not want to work (Tried Lazarus 1.8.4/FPC 3.0.4, Lazarus 2.0.0/FPC 3.0.4 with Apache 2.4, on Linux x86_64, though the OS should not matter with fcl-web). So, after I could not make my original project work with the newer fcl-web, I have created a basic Lazarus project: File -> New -> CGI Application, and added a default action that just returns a simple html page: procedure Tblahblah.WebDefaultActionRequest(Sender: TObject;   ARequest: TRequest; AResponse: TResponse; var Handled: Boolean); begin   Handled := true;   AResponse.Content := '<html><body>This function is not implemented yet. ' + DateTimeToStr(Now) + '</body></html>'; end; This one did not work either. Tried in docker with apache-alpine, docker with apache, heck, even put it on my live Ubuntu 16.04 with Apache web server at the end, with the same result, an error HTML page from the CGI application: "The application encountered the following error:     Error: Not found     Stack trace:     $0000000000499B40     $00000000004990EF" Did anyone test this fcl-web part lately? BTW, A simple CGI application works OK (File -> New -> Custom CGI Application), though there are no Actions, of course: Procedure TMyCGIHandler.HandleRequest(ARequest : Trequest; AResponse : TResponse); begin   // Your code here   AResponse.Content := '<html>Something. (' + ARequest.QueryString + ')</html>'; end; Any reproduction or help is appreciated.

Just a guess: does adding "Application.LegacyRouting := True;" in the main source file fix the problem?
If so then you should read up on the differences between the old, legacy routing and the newer more flexible one here:
http://wiki.lazarus.freepascal.org/fpWeb_Tutorial#Routing

Regards,
Sven

Michael Van Canneyt
to AB: I have tried to update my old web project that is in maintenance mode since a few years…
AB wrote 8 lines
Hi Guys, I have tried to update my old web project that is in maintenance mode since a few years now, using the latest stable Lazarus/FPC, and fcl-web just does not want to work (Tried Lazarus 1.8.4/FPC 3.0.4, Lazarus 2.0.0/FPC 3.0.4 with Apache 2.4, on Linux x86_64, though the OS should not matter with fcl-web).

[snip]

Did anyone test this fcl-web part lately?

Yes, yesterday only. I added a new web module type...

BTW, A simple CGI application works OK (File -> New -> Custom CGI Application), though there are no Actions, of course: Any reproduction or help is appreciated.

As Sven recommended, please check the LegacyRouting and new routing mechanism.
http://wiki.lazarus.freepascal.org/fpWeb_Tutorial#Routing with legacyrouting the 'old' code is executed when determining the module.

Michael.

AB
to Michael Van Canneyt

Indeed, this has fixed it. Thank you guys.

AB

Michael Van Canneyt wrote 33 lines
On Tue, 26 Feb 2019, AB wrote: > Hi Guys, > > I have tried to update my old web project that is in maintenance mode > since a few years now, using the latest stable Lazarus/FPC, and > fcl-web just does not want to work (Tried Lazarus 1.8.4/FPC 3.0.4, > Lazarus 2.0.0/FPC 3.0.4 with Apache 2.4, on Linux x86_64, though the > OS should not matter with fcl-web). > [snip] > Did anyone test this fcl-web part lately? Yes, yesterday only. I added a new web module type... > BTW, A simple CGI application works OK (File -> New -> Custom CGI > Application), though there are no Actions, of course: > > Any reproduction or help is appreciated. As Sven recommended, please check the LegacyRouting and new routing mechanism. http://wiki.lazarus.freepascal.org/fpWeb_Tutorial#Routing with legacyrouting the 'old' code is executed when determining the module. Michael. _______________________________________________ fpc-pascal maillist  -  http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal