program Project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes,SysUtils, fphttpapp, httpdefs, httproute, fpjson, jsonparser, interfaces,forms,Unit1;
type
TWebServerThread = class(TThread)
protected
procedure Execute; override;
public
constructor Create(CreateSuspended: boolean);
end;
constructor TWebServerThread.Create(CreateSuspended: boolean);
begin
inherited Create(CreateSuspended);
FreeOnTerminate := true;
end;
procedure TWebServerThread.Execute;
begin
fphttpapp.Application.Run;
end;
procedure test(req: TRequest; res: TResponse);
var
s:string;
rawJson: AnsiString;
people: TJSONArray;
person: TJSONObject;
personEnum: TJSONEnum;
begin
// Get the JSON data
rawJson:=req.Content;
writeln(rawjson);
form1.frReport1.LoadFromFile('test.lrf');
form1.frReport1.ShowReport;
end;
begin
fphttpapp.Application.Port := 8000;
HTTPRouter.RegisterRoute('/test', @test, true);
fphttpapp.Application.Threaded := true;
fphttpapp.Application.Initialize;
TWebServerThread.Create(false);
RequireDerivedFormResource:=True;
Forms.Application.Scaled:=True;
Forms.Application.Initialize;
Forms.Application.CreateForm(TForm1, Form1);
Forms.Application.Run;
end.