-
Notifications
You must be signed in to change notification settings - Fork 3
/
httpsrv.pas
54 lines (40 loc) · 828 Bytes
/
httpsrv.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
unit httpsrv;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, fphttpapp, httproute;
type
{ TServerThread }
TServerThread = class(TThread)
private
function GetPort: word;
protected
procedure Execute; override;
public
property Port: word read GetPort;
constructor Create(const APort: word);
procedure StopServer;
end;
implementation
{ TServerThread }
function TServerThread.GetPort: word;
begin
Result:=Application.Port;
end;
procedure TServerThread.Execute;
begin
Application.Initialize;
Application.Run;
end;
constructor TServerThread.Create(const APort: word);
begin
inherited Create(True);
Application.Title:='Supervisor';
Application.Port:=APort;
Application.Threaded:=True;
end;
procedure TServerThread.StopServer;
begin
Application.Terminate;
end;
end.