The
Clever Internet Suite library provides a special TclSimpleHttpServer component that works in single-threaded blocking mode.
The example starts listening the socket in a loop. Incoming requests are accepted until you request a specific URL in your web browser.
If you are looking for a multi-threaded HTTP server component for Delphi, please check out the following
Article, the sources are available on
GitHub
server := TclSimpleHttpServer.Create(nil);
try
repeat
server.Listen(80);
request := server.AcceptRequest();
uri := server.RequestUri;
server.ResponseHeader.ContentType := 'text/html';
server.KeepConnection := False;
if (Pos('stop', uri) > 0) then
begin
server.SendResponse(200, 'OK', '<html><body>Server stopped.</body></html>');
Break;
end;
server.SendResponse(200, 'OK', '<html><body>Your requested the ' + uri + ' resource.</body></html>');
until False;
finally
server.Free();
end;
Article ID: 93, Created: November 24, 2017 at 12:18 PM, Modified: November 20, 2019 at 11:30 PM