Page 1 of 1

Simple CGI help

Posted: Tue Aug 12, 2003 2:25 am
by griz
I have attempted to write a few CGI utilities in both Blitz and Pure Basic without much luck. I don't want to bother with Perl. I came across the following link : http://computer.howstuffworks.com/cgi3.htm which really simplifies how CGI works. The simplest example in C being :

Code: Select all

#include <stdio.h>

int main()
{
  printf("Content-type: text/html\n\n");
  printf("<html>\n");
  printf("<body>\n");
  printf("<h1>Hello there!</h1>\n");
  printf("</body>\n");
  printf("</html>\n");
  return 0;
}

I download the LCCWIN32 compiler, never having used it before, pasted the code above into it, "make" the exe and test it on my server. Works the first time. So quick, so simple. Written in C.

Would someone kindly walk me through the same process using Pure Basic? :)

Posted: Tue Aug 12, 2003 3:02 am
by Paul
Sure... download the great ASM library called CGI (written by El Choni) from the Resources Site.

Then your code would translate like this:

Code: Select all

n.s=Chr(13)+Chr(10)
StdOut("Content-type: text/html"+n+n) 
StdOut("<html>"+n) 
StdOut("<body>"+n)
StdOut("<h1>Hello there!</h1>"+n) 
StdOut("</body>"+n) 
StdOut("</html>"+n)

The entire PureBasic Resources Site is run from a CGI app written in PureBasic using El_Choni's CGI library.

Posted: Tue Aug 12, 2003 7:13 am
by griz
Thanks Paul, that works great. The LCC generated EXE was 10.9KB and the Pure Basic EXE was only 4.53KB (and compresses to only 3.03KB with upx). Again, thanks.