Welcome, Guest
Username: Password: Remember me
Components and Libraries for Web Development, discussions, problems and suggestions
  • Page:
  • 1

TOPIC:

Web beginner problems 8 years 9 months ago #7420

  • usbdoo
  • usbdoo's Avatar Topic Author
  • Visitor
  • Visitor
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.

Web beginner problems 8 years 9 months ago #7423

  • Tony_O_Gallos
  • Tony_O_Gallos's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Ελεύθερο λογισμικό ή θάνατος
  • Posts: 84
  • Thank you received: 23
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.

Web beginner problems 8 years 9 months ago #7432

  • usbdoo
  • usbdoo's Avatar Topic Author
  • Visitor
  • Visitor
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.

Web beginner problems 8 years 9 months ago #7434

  • Tony_O_Gallos
  • Tony_O_Gallos's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Ελεύθερο λογισμικό ή θάνατος
  • Posts: 84
  • Thank you received: 23
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.

Web beginner problems 8 years 9 months ago #7436

  • usbdoo
  • usbdoo's Avatar Topic Author
  • Visitor
  • Visitor
Thank you.
I install Apache .
I copied the cgi to /usr/lib/cgi-bin/
CGI Hello is now displayed.

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

Last edit: by usbdoo.

Web beginner problems 8 years 9 months ago #7437

  • Tony_O_Gallos
  • Tony_O_Gallos's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Ελεύθερο λογισμικό ή θάνατος
  • Posts: 84
  • Thank you received: 23

/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/

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

Last edit: by Tony_O_Gallos.

Web beginner problems 8 years 9 months ago #7438

  • usbdoo
  • usbdoo's Avatar Topic Author
  • Visitor
  • Visitor
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.

Web beginner problems 8 years 9 months ago #7439

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4506
  • Thank you received: 1100
Guys
In final CT 5.40 we will have so many new Web Programming abilities...
PilotLogic Architect and Core Programmer
The following user(s) said Thank You: atlandev.ct

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

Last edit: by Sternas Stefanos.

Web beginner problems 8 years 9 months ago #7440

  • usbdoo
  • usbdoo's Avatar Topic Author
  • Visitor
  • Visitor
Excellence news.
I can hardly wait.

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

Web beginner problems 8 years 8 months ago #7738

  • usbdoo
  • usbdoo's Avatar Topic Author
  • Visitor
  • Visitor
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.

  • Page:
  • 1