CGI ( fpweb ) | fpc 3.0.4 | Lazarus 1.8 does not work lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- cpalx · 2018-01-29 02:54 Hello, I have Lazarus 1.8 ith FP 3.0.4, I am making some simple CGI programs, all compile, but none works. Display ============== The application encountered the following error:     Error: Not found     Stack trace:     $0000000000499C00     $00000000004991AF ============== Same with the examples ---------------------------------------------------------------------- nummer8 · 2018-01-29 08:43 There is a new routing system in added to fp-web since Jan 2017. To run an application with the old routing system you must add the following line to the program Application.LegacyRouting := true; The examples are not updated yet. Jos ---------------------------------------------------------------------- cpalx · 2018-01-29 11:37 Thanks, and what about the new routing system ? ---------------------------------------------------------------------- Thaddy · 2018-01-29 11:40 Less sensitive to proxies. ---------------------------------------------------------------------- cpalx · 2018-01-29 11:51 Is there any example of the New Routine? ---------------------------------------------------------------------- nummer8 · 2018-01-29 12:21 In examples -> routing you can find the new routing mechanisms. See link for the changes http://free-pascal-general.1045716.n5.nabble.com/Changes-to-fpWeb- td5727306.html Jos ---------------------------------------------------------------------- egsuh · 2018-01-30 08:54 In this article, you are assuming that "old" routing should work without any change, but it works only when I set Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Application.LegacyRouting := true; ---------------------------------------------------------------------- egsuh · 2020-04-22 12:19 This is quite long time since the last posting to this topic, but now I got the answer and write here. The web server application supports both old and new routing methods, without following line.         Application.LegacyRouting := true; But I have to specify the web module name explicitly in the URL.  For example,        http://mysite/test/cgi_test.exe/cgi-test With legacyrouting true, I don't have to specify all of them if I only have one web module and action1 is defined as default action. Just following is fine.        http://mysite.com/test/cgi_test.exe (Of course, I do not add .exe in practice.) And I can use both routing methods together. I add a simple example. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit cgitest_u1; {$mode objfpc}{$H+} interface uses   SysUtils, Classes, httpdefs, fpHTTP, fpWeb, httproute; type   TFPWebModule1 = class(TFPWebModule)      procedure DataModuleRequest(Sender: TObject; ARequest: TRequest;         AResponse: TResponse; Var Handled: Boolean);      procedure HelloRequest(Sender: TObject; ARequest: TRequest;         AResponse: TResponse; var Handled: Boolean);   end; var   FPWebModule1: TFPWebModule1; implementation {$R *.lfm} procedure TFPWebModule1.DataModuleRequest(Sender: TObject; ARequest: TRequest;   AResponse: TResponse; Var Handled: Boolean);begin   AResponse.Content := 'Response from web module';    // Handled := True;end; procedure TFPWebModule1.HelloRequest(Sender: TObject; ARequest: TRequest;   AResponse: TResponse; var Handled: Boolean);begin   AResponse.Content := 'Hello, World';   Handled := True;end;  procedure DoSomething(ARequest: TRequest; AResponse: TResponse);begin   AResponse.Content := 'Response from DoSomething';   // Handled := True;end; initialization   // Httprouter.RegisterRoute('/', @Dosomething);  --> if this is set, this is the default behavior.    RegisterHTTPModule('cgi-test', TFPWebModule1);   Httprouter.RegisterRoute('/do', @Dosomething);end.