Example of a web application with lazarus lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- xinyiman · 2018-10-24 07:51 Hello guys, if you try to download from this link my project you will see that I have created an example (with comments in Italian) in which I demonstrate how to create a web application bootstrap (with MVC pattern). It is based on Indy to implement the web server that takes the template from html file. It is not perfect, because in unit unit_controller.pas the GetHTML function uses synapse to recover the html as it seems that synapse has a bug (arbitrarily does not always read me the content correctly and this makes me skip the validity of the json content) . www.lazaruspascal.it/esempi/ngit_bootstrap_application.zip Let me know your impressions ---------------------------------------------------------------------- xinyiman · 2018-10-24 08:44 I forgot to log in. The credentials are user: root pwd: 1234 ---------------------------------------------------------------------- Thaddy · 2018-10-24 09:16 In unit_gethtml I see some issues: - in the uses clause ssl_openssl is missing, which renders it a bit useless, since everybody uses https - the uses clause otherwise contains a lot of futile unused units, which slows down compile times. - Why do you writeCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         begin          page.LoadFromStream(http.Document);        for i:=0 to page.Count-1 do              risultato:=risultato + (page[i]);        end;Instead of: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         begin          page.LoadFromStream(http.Document);          risultato:=Page.Text; // <-------------        end;That is less error prone. In general it would be best to replace that function with synapse' standard function: I would write it like 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 unit unit_gethtml;{$mode objfpc}interfaceuses httpsend, ssl_openssl;  function RecuperaHtml(const Url: string): string; implementationuses classes; function RecuperaHtml(const Url: string): string;var  L:TStrings;begin  Result :='';  try    L := TStringlist.Create;    if HttpGetText(Url,L) then Result := L.Text;  finally    L.Free;  end;end; end.Advantages: - less error prone - allows redirects! - supports https