CGI/FCGI Hello World

LA.Docs
March 1st, 2016

This is a quick demonstration of creating your first CGI/FCGI Hello World application. You will need a HTTP Server with CGI/FCGI capabilities to run this application. For example: The Apache Server or The Litespeed Server


  1. Select from the menu: File - New Project
  2. Select your preferred Language on the left side
  3. Select “CGI (Common Gateway Interface)” as Project Type
  4. Enter a “mycgiapp” as Project Name
  5. Click on the “Create” button

LA.Developer will create your main project file and prepare the project to compile in CGI/FCGI mode.

6. Enter the following code at the “start conding here” comment

Basic Dialect:
    Response.setContent("Hello World")
 
C++, JScript Dialect:
    Response.setContent("Hello World");
 
Pascal Dialect:
    Response.setContent(’Hello World’);

LA.Developer can’t run CGI/FCGI applications. To be able to test a CGI/FCGI project you need to compile and deploy the project to a HTTP Server with CGI/FCGI capabilities. Alternatively you can start coding your project as a SERVER application which LA.Developer can run, and then transfer your code to a CGI/FCGI project. The Response/Request/Session objects are identical for SERVER and CGI/FCGI projects. In this tutorial however, we assume that we will use a Apache Server to run our application.

To compile your project:

  1. Select from the menu: Project - Select Build Targets
  2. Check mark the Operating System you want to target. (In this tutorial we are targeting Linux 64)
  3. Click on the “OK” button
  4. Select from the menu: Project - Build Project

We have now compiled our mycgiapp executable and will copy it to the cgi-bin directory of our Apache Server. Please consult Apache Manuals about setting up the cgi-bin directory and cgi execution permission.

Now let’s run and test our mycgiapp application.

  1. Open your favorite Browser
  2. Enter http://localhost:8181/cgi-bin/mycgiapp (Note: the port number is the number you used to setup Apache Server)

As we can see, the CGI/FCGI application was executed by the server and your response was printed.

That’s it.