Recent

Author Topic: CGI ( fpweb ) | fpc 3.0.4 | Lazarus 1.8 does not work  (Read 5267 times)

cpalx

  • Hero Member
  • *****
  • Posts: 753
CGI ( fpweb ) | fpc 3.0.4 | Lazarus 1.8 does not work
« on: January 29, 2018, 03:54:51 am »
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

  • Full Member
  • ***
  • Posts: 108
Re: CGI ( fpweb ) | fpc 3.0.4 | Lazarus 1.8 does not work
« Reply #1 on: January 29, 2018, 09:43:01 am »
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

  • Hero Member
  • *****
  • Posts: 753
Re: CGI ( fpweb ) | fpc 3.0.4 | Lazarus 1.8 does not work
« Reply #2 on: January 29, 2018, 12:37:13 pm »
Thanks, and what about the new routing system ?

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: CGI ( fpweb ) | fpc 3.0.4 | Lazarus 1.8 does not work
« Reply #3 on: January 29, 2018, 12:40:33 pm »
Less sensitive to proxies.
Specialize a type, not a var.

cpalx

  • Hero Member
  • *****
  • Posts: 753
Re: CGI ( fpweb ) | fpc 3.0.4 | Lazarus 1.8 does not work
« Reply #4 on: January 29, 2018, 12:51:13 pm »
Is there any example of the New Routine?

nummer8

  • Full Member
  • ***
  • Posts: 108
Re: CGI ( fpweb ) | fpc 3.0.4 | Lazarus 1.8 does not work
« Reply #5 on: January 29, 2018, 01:21:51 pm »
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

  • Hero Member
  • *****
  • Posts: 1273
Re: CGI ( fpweb ) | fpc 3.0.4 | Lazarus 1.8 does not work
« Reply #6 on: January 30, 2018, 09:54:23 am »
In this article, you are assuming that "old" routing should work without any change, but it works only when I set

Code: Pascal  [Select][+][-]
  1. Application.LegacyRouting := true;
  2.  

egsuh

  • Hero Member
  • *****
  • Posts: 1273
Re: CGI ( fpweb ) | fpc 3.0.4 | Lazarus 1.8 does not work
« Reply #7 on: April 22, 2020, 02:19:27 pm »
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][+][-]
  1. unit cgitest_u1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.    SysUtils, Classes, httpdefs, fpHTTP, fpWeb, httproute;
  9.  
  10. type
  11.    TFPWebModule1 = class(TFPWebModule)
  12.       procedure DataModuleRequest(Sender: TObject; ARequest: TRequest;
  13.          AResponse: TResponse; Var Handled: Boolean);
  14.       procedure HelloRequest(Sender: TObject; ARequest: TRequest;
  15.          AResponse: TResponse; var Handled: Boolean);
  16.    end;
  17.  
  18. var
  19.    FPWebModule1: TFPWebModule1;
  20.  
  21. implementation
  22.  
  23. {$R *.lfm}
  24.  
  25. procedure TFPWebModule1.DataModuleRequest(Sender: TObject; ARequest: TRequest;
  26.    AResponse: TResponse; Var Handled: Boolean);
  27. begin
  28.    AResponse.Content := 'Response from web module';
  29.    // Handled := True;
  30. end;
  31.  
  32. procedure TFPWebModule1.HelloRequest(Sender: TObject; ARequest: TRequest;
  33.    AResponse: TResponse; var Handled: Boolean);
  34. begin
  35.    AResponse.Content := 'Hello, World';
  36.    Handled := True;
  37. end;
  38.  
  39.  
  40. procedure DoSomething(ARequest: TRequest; AResponse: TResponse);
  41. begin
  42.    AResponse.Content := 'Response from DoSomething';
  43.    // Handled := True;
  44. end;
  45.  
  46. initialization
  47.    // Httprouter.RegisterRoute('/', @Dosomething);  --> if this is set, this is the default behavior.
  48.    RegisterHTTPModule('cgi-test', TFPWebModule1);
  49.    Httprouter.RegisterRoute('/do', @Dosomething);
  50. end.


« Last Edit: April 22, 2020, 02:26:23 pm by egsuh »

 

TinyPortal © 2005-2018