Recent

Author Topic: New to internet programming frustrations  (Read 9802 times)

dgrhoads

  • New Member
  • *
  • Posts: 39
New to internet programming frustrations
« on: March 30, 2024, 05:26:30 am »
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

  • Hero Member
  • *****
  • Posts: 16573
  • Kallstadt seems a good place to evict Trump to.
Re: New to internet programming frustrations
« Reply #1 on: March 30, 2024, 06:00:41 am »
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.
But I am sure they don't want the Trumps back...

TRon

  • Hero Member
  • *****
  • Posts: 3995
Re: New to internet programming frustrations
« Reply #2 on: March 30, 2024, 07:05:08 am »
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. 
The use of that unit is a choice (just like many others choices/dependencies for that package). See internettoolsconfig.inc

I 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:
Quote
Since 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).
« Last Edit: March 30, 2024, 07:19:57 am by TRon »
I do not have to remember anything anymore thanks to total-recall.

dgrhoads

  • New Member
  • *
  • Posts: 39
Re: New to internet programming frustrations
« Reply #3 on: March 30, 2024, 06:14:10 pm »
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

  • Hero Member
  • *****
  • Posts: 3995
Re: New to internet programming frustrations
« Reply #4 on: March 31, 2024, 07:06:28 am »
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.
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.

Quote
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.
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.

Quote
Are 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)
I do not have to remember anything anymore thanks to total-recall.

nummer8

  • Full Member
  • ***
  • Posts: 124
Re: New to internet programming frustrations
« Reply #5 on: March 31, 2024, 12:55:47 pm »
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

  • Hero Member
  • *****
  • Posts: 16573
  • Kallstadt seems a good place to evict Trump to.
Re: New to internet programming frustrations
« Reply #6 on: March 31, 2024, 07:17:58 pm »
Thanks 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.
But I am sure they don't want the Trumps back...

egsuh

  • Hero Member
  • *****
  • Posts: 1534
Re: New to internet programming frustrations
« Reply #7 on: April 02, 2024, 08:38:59 am »
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.


Quote
4. 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.
« Last Edit: April 02, 2024, 08:40:36 am by egsuh »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8786
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: New to internet programming frustrations
« Reply #8 on: April 02, 2024, 12:36:20 pm »
The 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.
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?
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][+][-]
  1. uses
  2.   fphttpapp, httpdefs, httproute;
  3.  
  4. procedure DoHello(ARequest:TRequest; AResponse : TResponse);
  5. begin
  6.   AResponse.Content:='<html><body><h1>Hello,World!</h1></body></html>'
  7. end;
  8.  
  9. begin
  10.   HTTPRouter.RegisterRoute('*', @DoHello);
  11.   Application.Port := 9000;
  12.   Application.Initialize;
  13.   Application.Run;
  14. end.
  15.  
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

  • New Member
  • *
  • Posts: 33
Re: New to internet programming frustrations
« Reply #9 on: January 25, 2025, 05:55:45 pm »
... write a new ...
Code: Pascal  [Select][+][-]
  1. port <= 1023 -->
  2. > www-server start on port: 1023
  3. Exception at 0000000000497D98: ESocketError:
  4. Binding of socket failed: 1023.
  5.  
web-server is default 80-port  :o
« Last Edit: January 25, 2025, 05:57:19 pm by sunjob »

Thaddy

  • Hero Member
  • *****
  • Posts: 16573
  • Kallstadt seems a good place to evict Trump to.
Re: New to internet programming frustrations
« Reply #10 on: January 25, 2025, 06:18:27 pm »
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.
« Last Edit: January 25, 2025, 06:21:29 pm by Thaddy »
But I am sure they don't want the Trumps back...

sunjob

  • New Member
  • *
  • Posts: 33
Re: New to internet programming frustrations
« Reply #11 on: January 25, 2025, 06:34:36 pm »
... during web server development use ...
It's strange somehow?! Why should we limit ourselves?! Who invented this?!  ;D
Quote
Use port 80 only for deployment.
-->
Code: Pascal  [Select][+][-]
  1. Exception at 0000000000497D98: ESocketError:
  2.  

Quote
port <= 1023
deciphered as "any port below 1024", that is, 80-port also

p.s.
Code: Pascal  [Select][+][-]
  1. sudo web_app # start is OK on 80 port
  2.  
« Last Edit: January 27, 2025, 07:27:47 pm by sunjob »

dbannon

  • Hero Member
  • *****
  • Posts: 3223
    • tomboy-ng, a rewrite of the classic Tomboy
Re: New to internet programming frustrations
« Reply #12 on: January 25, 2025, 11:41:01 pm »
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.
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
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Leledumbo

  • Hero Member
  • *****
  • Posts: 8786
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: New to internet programming frustrations
« Reply #13 on: January 29, 2025, 06:23:27 pm »
web-server is default 80-port  :o
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

  • New Member
  • *
  • Posts: 33
Re: New to internet programming frustrations
« Reply #14 on: January 29, 2025, 11:05:24 pm »
certainly it's not my hello world example.
The given code is: o)

 

TinyPortal © 2005-2018