× Components and Libraries for Web Development, discussions, problems and suggestions

Question Web beginner problems

  • usbdoo
  • Topic Author
  • Visitor
  • Visitor
5 years 2 months ago #7420 by usbdoo
Web beginner problems was created by usbdoo
I am a beginner in web programming.
I need help getting started test sample
/usr/lib/codetyphon/CodeOcean/Indy/samples/HTTPServer
I successfully tested HTTPServer;

I would ask for help?
How this instance call in httpserver;
/usr/lib/codetyphon/CodeOcean/SolutionsWeb/samples/Hello


**************************************************************
program Hello;
{$mode objfpc}{$H+}
uses
LWSCGI;
type
{ TCGI }
TCGI = class(TLWSCGI)
protected
procedure Respond; override;
end;
procedure TCGI.Respond;
begin
Contents.Add('<!DOCTYPE HTML>');
Contents.Add('<html lang="en-US">');
Contents.Add('<head>');
Contents.Add(' <meta charset="UTF-8">');
Contents.Add(' <title>Hello</title>');
Contents.Add('</head>');
Contents.Add('<body>');
Contents.Add(' Hello world! :)');
Contents.Add('</body>');
Contents.Add('</html>');
end;
begin
with TCGI.Create do
try
Run;
finally
Free;
end;
end.
******************************************************
Thanks

Please Log in or Create an account to join the conversation.

  • Tony_O_Gallos
  • Tony_O_Gallos's Avatar
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Ελεύθερο λογισμικό ή θάνατος
More
5 years 2 months ago #7423 by Tony_O_Gallos
Replied by Tony_O_Gallos on topic Web beginner problems
Hi usbdoo,

you are trying to mix two types of concepts.
Indy HTTPServer is a fully independant web server (lets say like Apache).
You have to process all the commands internally and send back the response, taking account of HTTP specifications.

"Hello" is a CGI , it is a binary you call from command line, like a batch/exe.
Instead of to be located in the path, it resides on a web server and you feed it with parameters in the URL.

Let's take the case of Apache.
Basically it does nothing special.
But you can add some interpreters to make it dynamic like PHP, Perl, Python and so on...
You can use them either as "Plugins" (mod_php) or CGI using mod_cgi (php-cli) called externally

I would not advice you to do web programming directly with Indy or even CGI.
They are done for specific needs, you have to handle everything about HTML and HTTP protocol, headers, ...
These examples are "web servers programming" not "web programming", to make "filters"/"modifiers"
Better to stick to traditional web development, with interpreters like PHP or NodeJS :P
(Client request -> web server response as html)
The following user(s) said Thank You: usbdoo

Please Log in or Create an account to join the conversation.

  • usbdoo
  • Topic Author
  • Visitor
  • Visitor
5 years 2 months ago #7432 by usbdoo
Replied by usbdoo on topic Web beginner problems
I still do not know how to do.
Please for the sample, how to call this CGI with html coda.

/usr/lib/codetyphon/CodeOcean/SolutionsWeb/samples/Hello.

Thanks

Please Log in or Create an account to join the conversation.

  • Tony_O_Gallos
  • Tony_O_Gallos's Avatar
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Ελεύθερο λογισμικό ή θάνατος
More
5 years 2 months ago #7434 by Tony_O_Gallos
Replied by Tony_O_Gallos on topic Web beginner problems
1- Compile your CGI program
2- Move it in the cgi-bin directory of your web server
3- Call it from the Web Browser from http://youradress/cgi-bin/hello/

You don't have a web server ?
Install one :P
Under Linux there are a lot of tutorials for LAMP install (Apache + MySQL + PHP)
Under Windows you can install packages like EasyPHP, Vertrigo, XAMPP
But you will have to configure/enable mod_cgi and place your program in the proper path...

CGI is a rather old technology (forget it :P)
Once again, it doesn't worth to lose your time with this, better learn basic PHP to produce HTML + javascript for your web application.

The good part is that if you install a LAMP/WAMP environment to test the CGI, you will have it already ready for other purposes ;)

Please Log in or Create an account to join the conversation.

  • usbdoo
  • Topic Author
  • Visitor
  • Visitor
5 years 2 months ago - 5 years 2 months ago #7436 by usbdoo
Replied by usbdoo on topic Web beginner problems
Thank you.
I install Apache .
I copied the cgi to /usr/lib/cgi-bin/
CGI Hello is now displayed.
Last edit: 5 years 2 months ago by usbdoo.

Please Log in or Create an account to join the conversation.

  • Tony_O_Gallos
  • Tony_O_Gallos's Avatar
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Ελεύθερο λογισμικό ή θάνατος
More
5 years 2 months ago - 5 years 2 months ago #7437 by Tony_O_Gallos
Replied by Tony_O_Gallos on topic Web beginner problems

/usr/lib/codetyphon/CodeOcean/SolutionsWeb/samples/Login/readme.txt wrote: Very simple login demo. (is not a secure login system!)

Configure the CGI executable to find the HTML files (eg. copy all HTMLs to cgi-bin folder).

Enjoy!

CGI are using the file system directory as it is an executable.
You can of course change its location by modification of virtualhosts in /etc/apache2
By default, your html files reachable by the web server are located in /var/www on debian/*buntu family.
But it is "logical" mapping http:/localhost points at /var/www while http://localhost/cgi-bin points at /usr/lib/cgi-bin/

Really, abandon CGI :P

More info here wiki.lazarus.freepascal.org/CGI_Web_Programming
You should consider using Brook ;) silvioprog.github.io/brookframework/
Last edit: 5 years 2 months ago by Tony_O_Gallos.

Please Log in or Create an account to join the conversation.

  • usbdoo
  • Topic Author
  • Visitor
  • Visitor
5 years 2 months ago #7438 by usbdoo
Replied by usbdoo on topic Web beginner problems
Very kind of you,
to explain in detail.
Web is not my main focus.
But programming is my job.
Web is a more relaxation and enjoyment exploration.
.
Best greetings is Slovenia.

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Away
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
5 years 2 months ago - 5 years 2 months ago #7439 by Sternas Stefanos
Replied by Sternas Stefanos on topic Web beginner problems
Guys
In final CT 5.40 we will have so many new Web Programming abilities...

PilotLogic Architect and Core Programmer
Last edit: 5 years 2 months ago by Sternas Stefanos.
The following user(s) said Thank You: atlandev.ct

Please Log in or Create an account to join the conversation.

  • usbdoo
  • Topic Author
  • Visitor
  • Visitor
5 years 2 months ago #7440 by usbdoo
Replied by usbdoo on topic Web beginner problems
Excellence news.
I can hardly wait.

Please Log in or Create an account to join the conversation.

  • usbdoo
  • Topic Author
  • Visitor
  • Visitor
5 years 3 weeks ago #7738 by usbdoo
Replied by usbdoo on topic Web beginner problems
Hi sternas.

You're saying

In final CT 5.40 we will have so many new Web Programming abilities


Can you help me.
How to find samples for the new Web Programming abilities?
Thanks

Please Log in or Create an account to join the conversation.