I want something to receive HTTP POSTs from another device lazarus / 16-Databases ---------------------------------------------------------------------- Sheepdog · 2022-08-27 07:23 I think I can create an Arduino that will send HTTP "POST" messages from time to time. (When the POST should be sent would be up to the Arduino.) I want to write something in Lazarus to run in a second computer. One sitting on my LAN, standing by to receive POST messages. Let's say the content of the POST is "At 21:45 temperature was 12.6 C". I want the Lazarus program to append that to a text file held on the hard drive of the computer the Lazarus program is running on. (I can already write an app to add the contents of an edit box to a text file (and clear the edit box) every time a user typed something and then pressed Enter.) ---------------------------------------------------------------------- dje · 2022-08-27 07:44 You need TFPHTTPServer from the unit fphttpserver, which comes with FreePascal. There is an example here: https://github.com/alrieckert/freepascal/blob/master/packages/fcl- web/examples/httpserver/simplehttpserver.pas ---------------------------------------------------------------------- Sheepdog · 2022-08-27 11:41 Many thanks, dje! You've taken me further down the road, I think. If others reading this want to do what I want to do, on a Windows machine it SEEMS that you just rem out the wmecho library from the "Uses" clause. (That WILL fix some things. I don't know that it doesn't break others. I could find little on the web about wmecho... anyone with information would do us all a favor by posting it here? I've put other notes about my "one-eyed-king-with a blindfold on" stmblings in the dark at... https://trixiesgems.com/category/programming/lazarus/ ---------------------------------------------------------------------- dje · 2022-08-27 12:16 If you haven't written http servers before, I think its best to start with the simplest example, so you can see how this stuff actually works. It is kinda fun. So, start with a simple console server: 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 VerySimpleHttpServer; uses SysUtils, fphttpserver; type TMySimpleServer = class(TFPHttpServer) public procedure HandleRequest(var ARequest: TFPHTTPConnectionRequest; var AResponse: TFPHTTPConnectionResponse); override; end; procedure ShowMe(const AName, AValue: string); begin WriteLn(AName, ': ', AValue); end; procedure TMySimpleServer.HandleRequest(var ARequest: TFPHTTPConnectionRequest; var AResponse: TFPHTTPConnectionResponse); begin inherited; ShowMe('Method', ARequest.Method); ShowMe('UserAgent', ARequest.UserAgent); ShowMe('PathInfo', ARequest.PathInfo); ShowMe('Query', ARequest.Query); ShowMe('URL', ARequest.URL); if Assigned(ARequest.QueryFields) then begin ShowMe('QueryFields', ARequest.QueryFields.CommaText); end; if Assigned(ARequest.ContentFields) then begin ShowMe('ContentFields', ARequest.ContentFields.CommaText); end; with AResponse.Contents do begin Add('
'); Add('