Ignore:
Timestamp:
Apr 29, 2012, 9:41:43 PM (13 years ago)
Author:
chronos
Message:
  • Modified: WebApp is not TComponent instead of TCustomApplication. TApplication in Forms unit is used as base application class.
  • Added: Experimental HTTPServerTurboPower as HTTPServer type which can be used for web application development without external web browser. If used, form with TurboPowerIPro panel will be displayed. This requeire some LCD widgetset other then nogui.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Network/CoolWeb/WebServer/UWebApp.pas

    r311 r357  
    77uses
    88  Classes, SysUtils, CustApp, SpecializedList, UWebPage, UHTTPSessionFile,
    9   UHTTPServer;
     9  UHTTPServer, Forms;
    1010
    1111type
    12   THTTPServerType = (stCGI, stTCP);
     12  THTTPServerType = (stCGI, stTCP, stTurboPower);
    1313
    1414  TRegistredPage = class
     
    2525  { TWebApp }
    2626
    27   TWebApp = class(TCustomApplication)
     27  TWebApp = class(TComponent)
    2828  private
    2929    FOnBeforePageProduce: TOnProduceEvent;
    3030    FOnInitialize: TNotifyEvent;
    3131    FServerType: THTTPServerType;
    32     procedure DoRun; override;
    3332    function DumpExceptionCallStack(E: Exception): string;
    3433    procedure HTTPServerRequest(HandlerData: THTTPHandlerData);
     
    3938    HTTPSessionStorageFile: THTTPSessionStorageFile;
    4039    LogException: Boolean;
    41     procedure ShowException(E: Exception); override;
     40    procedure ShowException(E: Exception);
    4241    procedure RegisterPage(PageClass: TWebPageClass; out Reference; Path: string);
    4342    constructor Create(AOwner: TComponent); override;
    4443    destructor Destroy; override;
     44    procedure Run;
     45  published
    4546    property OnBeforePageProduce: TOnProduceEvent read FOnBeforePageProduce write FOnBeforePageProduce;
    4647    property OnInitialize: TNotifyEvent read FOnInitialize write FOnInitialize;
     
    5152procedure Register;
    5253
    53 var
    54   Application: TWebApp;
    55 
    56 
    5754implementation
    5855
    5956uses
    60   UHTTPServerCGI, UHTTPServerTCP;
     57  UHTTPServerCGI, UHTTPServerTCP, UHTTPServerTurboPower;
    6158
    6259resourcestring
     
    6663procedure Register;
    6764begin
    68   RegisterClass(TWebApp);
     65  RegisterComponents('CoolWeb', [TWebApp]);
    6966end;
    7067
     
    8481{ TWebApp }
    8582
    86 procedure TWebApp.DoRun;
     83procedure TWebApp.Run;
    8784begin
    88   try
    89     if Assigned(FOnInitialize) then FOnInitialize(Self);
    90     HTTPServer.Run;
    91   finally
    92     Terminate;
    93   end;
     85  if Assigned(FOnInitialize) then FOnInitialize(Self);
     86  HTTPServer.Run;
     87  if (ServerType = stCGI) or (ServerType = stTCP) then
     88    Application.Terminate;
    9489end;
    9590
     
    155150    stCGI: HTTPServer := THTTPServerCGI.Create(nil);
    156151    stTCP: HTTPServer := THTTPServerTCP.Create(nil);
     152    stTurboPower: HTTPServer := THTTPServerTurboPower.Create(nil);
    157153  end;
    158154  HTTPServer.OnRequest := HTTPServerRequest;
     
    198194initialization
    199195
    200 Application := TWebApp.Create(nil);
    201 
    202 
    203196finalization
    204 
    205 Application.Free;
    206197
    207198end.
Note: See TracChangeset for help on using the changeset viewer.