Embedded webserver and httprourer lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- ldvmikro · 2020-08-25 07:53 Hello, I use embedded webserver based on fpweb unit an in the current stage I need routing of different requests. I tried to use Route Syntax described her https://wiki.lazarus.freepascal.org/fpWeb_Tutorial, but no luck, its not working with embedded server, only with simple http server realization such as this: Code: Pascal [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i HTTPRouter.RegisterRoute('*', @DoHello); Application.Port := 9000; Application.Initialize; Application.Run; This is my code that describe and starting my webserver Code: Pascal [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type THTTPServerThread = class(TThread) strict private FServer: TFPHTTPServer; FRequest: TFPHTTPConnectionRequest; FResponse: TFPHTTPConnectionResponse; procedure DoHandleRequest(Sender: TObject; var ARequest: TFPHTTPConnectionRequest; var AResponse: TFPHTTPConnectionResponse); procedure ShowRequest; protected procedure Execute; override; public constructor Create(APort: Word); destructor Destroy; override; procedure StopServer; end; { THTTPServerThread }constructor THTTPServerThread.Create(APort: Word);begin inherited Create(True); FServer := TFPHttpServer.Create(nil); FServer.Port := APort; FServer.OnRequest := @DoHandleRequest; FreeOnTerminate := True;end; destructor THTTPServerThread.Destroy;begin FServer.Free; inherited;end; procedure THTTPServerThread.Execute;begin FServer.Active := True;end; procedure THTTPServerThread.StopServer;begin FServer.Active := False;end; FThread := THTTPServerThread.Create(9080); FThread.OnTerminate := @ThreadTerminated; Please help, when should put HTTPRouter.RegisterRoute line for requests routing? Thanks ---------------------------------------------------------------------- PierceNg · 2020-08-25 15:50 Embedded server = simple HTTP server, no? The other options mentioned on that wiki page are CGI, FastCGI, Apache module, libmicrohttpd and Windows kernel HTTP server. Here's a multi threaded example with 2 routes using new-style routing. Code: Pascal [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program tworoutes; {$mode objfpc}{$H+} uses {$ifdef UNIX}cthreads, cmem,{$endif} fphttpapp, httpdefs, httproute; procedure route1(aReq: TRequest; aResp: TResponse);begin aResp.content:='