New to internet programming frustrations lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- dgrhoads · 2024-03-30 04:26 I am new to programming for internet access and am finding that the three avenues I've tried so far have issues.  My third avenue is InternetTools.   It seems to be widely used. I downloaded the internettools.zip and have tried to install the package "internettools.lpk".  During installation, I got an error message telling me that it cannot find PASDBLSTRUTILS.  This file is not included in the latest Lazarus distribution nor in the InternetTools zip file.  I fouund it on the internet and have downloaded it.  Where do I put this file so it will be available every future time I rebuild my system and where it will be compiled along with all the other files during the rebuild? ---------------------------------------------------------------------- Thaddy · 2024-03-30 05:00 internettools is a bad choice. very old. and contrary to your belief hardly used anymore. look at the preinstalled fcl-web and fpc-net libraries and the included examples. there also some component wrappers for that. it is maintained and written by the freepascal core team. you may also be interested in pas2js, but for beginners i would start with first two in mentioned. ---------------------------------------------------------------------- TRon · 2024-03-30 06:05 Quote from: dgrhoads on March 30, 2024, 05:26:30 amI downloaded the internettools.zip and have tried to install the package "internettools.lpk".  During installation, I got an error message telling me that it cannot find PASDBLSTRUTILS.  The use of that unit is a choice (just like many others choices/dependencies for that package). See internettoolsconfig.inc Quote from: dgrhoads on March 30, 2024, 05:26:30 amI downloaded the internettools.zip  .... From where ? When ? Always try to go directly to the source, like in this case here. PS: something I forgot to mention. Internetools are just plain Pascal units e.g. there are no visual components. and as stated on the website: QuoteSince the Internet Tools and their XQuery-Engine consist of a set of plain Pascal units they do not require installation. You just need to extract all files from the .zip package and ensure that FPC can find the .pas files. But if you want to then the package can be installed (with the earlier mentioned note about the configuration in mind). ---------------------------------------------------------------------- dgrhoads · 2024-03-30 17:14 Thanks for the suggestions. I successfully loaded the fpweb package.  Then I attempted to follow the directions in two of the website tutorials suggested by TRon.  (I am using the latest Lazarus distribution 3.2.)  Partial success.  Frustrations continue. fpWeb Tutorial.  I tried the "Hello World" example.  Used the HTTP Server Application.  In Item #5, I was directed to move to the Object Inspector.  There were NO objects available under Object Inspector.  Consequently, I could not select an event as specified under Item #6. fcl-web.  I was able to create the first application (CGI Application) as directed.  I was able to compile it successfully (Run/Quick compile).  However the normally green arrow used to launch the application was not illuminated, so I couldn't run the application. Are these bugs in 3.2 that I am finding or is it me? Is it possible to use fpweb with a straight Application rather than the HTTP Server Application or the CGI Application?  If so, is there a tutorial on how to do that? ---------------------------------------------------------------------- TRon · 2024-03-31 05:06 Quote from: dgrhoads on March 30, 2024, 06:14:10 pmfpWeb Tutorial.  I tried the "Hello World" example.  Used the HTTP Server Application.  In Item #5, I was directed to move to the Object Inspector.  There were NO objects available under Object Inspector.  Consequently, I could not select an event as specified under Item #6. Which type of web module did you select on the HTTP project creation window ? If you leave it empty non will be created and hence there will not be any presented in the object inspector. Quotefcl-web.  I was able to create the first application (CGI Application) as directed.  I was able to compile it successfully (Run/Quick compile).  However the normally green arrow used to launch the application was not illuminated, so I couldn't run the application. A CGI application does not run on its own (it is an extension for an existing/running server). To my knowledge there is no default provision in Lazarus configured for that. QuoteAre these bugs in 3.2 that I am finding or is it me? Wiki tutorial not being updated and rough edges (though the latter, I am not sure if Lazarus should also be able to act as a http daemon) ---------------------------------------------------------------------- nummer8 · 2024-03-31 10:55 Marcus Fernstrom wrote a few articles on freepascal and internet on medium https://medium.com/@marcusfernstrm Serving static webpages https://medium.com/@marcusfernstrm/serve-static-webpages-with- freepascal-c0d9c9dee352 Creating Rest API's https://medium.com/@marcusfernstrm/create-rest-apis-with- freepascal-441e4aa447b7 and several related issues. ---------------------------------------------------------------------- Thaddy · 2024-03-31 17:17 Quote from: dgrhoads on March 30, 2024, 06:14:10 pmThanks for the suggestions. I successfully loaded the fpweb package. Which is strange because it is already in the fpc distribution. Such things can only cause harm. and fcl-web is packed full of examples. fcl-web used to be called fpweb so that is definitely old. ---------------------------------------------------------------------- egsuh · 2024-04-02 06:38 Hello, The Tutorial is outdated --- recent Lazarus is slightly different. You may add Webmodule at the creation of New (Http server) application, as in the attached image. Probably the red-circled part is not in the tutorial. But as you have already created the project (without webmodule), you can add it. Go to main menu File > New > WebModule, and press OK. Then you may resume at #5 of the Tutorial. Quote4. Whatever you choose, pick "OK" and you'll be presented in the default one module fpWeb app. 5. Focus the module and move to Object Inspector. Feel free to rename the module if you wish. Don't get frustrated. Here are some people to advise you. ---------------------------------------------------------------------- Leledumbo · 2024-04-02 10:36 Quote from: egsuh on April 02, 2024, 08:38:59 amThe Tutorial is outdated --- recent Lazarus is slightly different. Part is me to blame as the original author of the article, I assume people will contribute and update accordingly. Turns out my assumption is wrong. Quote from: dgrhoads on March 30, 2024, 06:14:10 pmIs it possible to use fpweb with a straight Application rather than the HTTP Server Application or the CGI Application?  If so, is there a tutorial on how to do that? You can even use it without any IDE, just a text editor. As written in the New Mechanism part of my tutorial: 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 uses  fphttpapp, httpdefs, httproute; procedure DoHello(ARequest:TRequest; AResponse : TResponse);begin  AResponse.Content:='

Hell o,World!

'end; begin  HTTPRouter.RegisterRoute('*', @DoHello);  Application.Port := 9000;  Application.Initialize;  Application.Run;end. is all you need to get a working "Hello, World" example. I should probably write a new tutorial ignoring everything that uses the form designer or even the IDE wizard. ---------------------------------------------------------------------- sunjob · 2025-01-25 16:55 Quote from: Leledumbo on April 02, 2024, 12:36:20 pm... write a new ... 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 port <= 1023 -->> www-server start on port: 1023Exception at 0000000000497D98: ESocketError:Binding of socket failed: 1023. web-server is default 80-port ---------------------------------------------------------------------- Thaddy · 2025-01-25 17:18 The routing example that comes with fcl-net/fcl-web works 100% Are you still trying to use old code? I warned you, don't do that. One more remark: during web server development use port 8000 or port 8080 or an arbitrary port higher than 8000 but lower than 32767. Use port 80 only for deployment. ---------------------------------------------------------------------- sunjob · 2025-01-25 17:34 Quote from: Thaddy on January 25, 2025, 06:18:27 pm... during web server development use ... It's strange somehow?! Why should we limit ourselves?! Who invented this?!  QuoteUse port 80 only for deployment.--> 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 Exception at 0000000000497D98: ESocketError:  Quoteport <= 1023deciphered as "any port below 1024", that is, 80-port also p.s. 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 sudo web_app # start is OK on 80 port ---------------------------------------------------------------------- dbannon · 2025-01-25 22:41 Quote from: Thaddy on March 31, 2024, 07:17:58 pmWhich is strange because it is already in the fpc distribution. Such things can only cause harm. and fcl-web is packed full of examples. fcl-web used to be called fpweb so that is definitely old. Correct but incomplete. Please look in your FPC Source dir (not sure how you installed FPC nor your platform so where that is is your problem) under packages/fcl-web/examples/ packages/fcl-net/examples/ They are (mostly?) command line examples, you can obviously incorporate that code into a gui but probably best to stay at the command line initially. You can still use Lazarus .... Davo ---------------------------------------------------------------------- Leledumbo · 2025-01-29 17:23 Quote from: sunjob on January 25, 2025, 05:55:45 pmweb-server is default 80-port  No, that's the default HTTP port if you don't specify one, which in actual production quality deployment is only done by the front most server, usually a load balancer. Anything behind and more behind can use arbitrary port allowed by the OS, typically something above 1024 as at least on Linux, anything 1024 or below requires sudo to bind due to security concerns. Plus, you show no code, certainly it's not my hello world example. ---------------------------------------------------------------------- sunjob · 2025-01-29 22:05 Quote from: Leledumbo on January 29, 2025, 06:23:27 pmcertainly it's not my hello world example. The given code is: o) ---------------------------------------------------------------------- Leledumbo · 2025-01-30 07:00 Quote from: sunjob on January 29, 2025, 11:05:24 pmThe given code is: o) Assuming that's true, then the rest of my explanation suffices. It's not a code related "problem", but understanding of concept implementation in OSes. ---------------------------------------------------------------------- sunjob · 2025-02-05 01:15 Quote from: Leledumbo on January 30, 2025, 08:00:13 amAssuming that's true... Thank you, I realized what the problem was, figured out access!