fphttpserver and httprouter lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- el3ctrolyte · 2020-08-22 00:50 Hello everyone, i was just wondering if it is possible to use fphttpserver with httprouter? I don not want to use fphttpapp, i want to create a fphttpserver object and have it somehow use httprouter. When i use fphttpapp and httprouter, it works. But when i make a fphttpserver object and use httprouter to register routes, it doesn't work. 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 Project1;uses    fphttpserver,httpdefs,httproute; Procedure hi(ARequest: TRequest; AResponse: TResponse);begin  AResponse.Contents.Add('

hi!

');end; var  httpsrv:TFPHttpServer;begin  httpsrv:=TFPHttpServer.Create(nil);  httpsrv.Active:=false;  httpsrv.Port:=8080;  HTTPRouter.RegisterRoute('/',@hi);  httpsrv.Active:=true;  readln;end. When i run this code, it doesn't give the "Hi!" i am looking for, just a blank web page. ---------------------------------------------------------------------- Leledumbo · 2020-08-22 07:14 You can't just do this. fphttpserver has no idea about httproute at all, they're not connected directly. It's custweb that knows httproute, and the various cust* (alongside end user fp*) units implement custweb interfaces of application, handler, request and response so they implicitly uses httproute. If you don't like any of those, you have to do the same in order to use httproute functionality. Or, explicitly uses HTTPRouter object in your OnRequest handler. ---------------------------------------------------------------------- el3ctrolyte · 2020-08-23 00:49 Thank you for your reply. This makes alot sense! I had thought that the interface to httproute was on the fphttpserver level and that fphttpapp was just a nice application wrapper for fphttpserver. Now i understand alot better!