Simple CGI help

Just starting out? Need help? Post your questions and find answers here.
User avatar
griz
Enthusiast
Enthusiast
Posts: 167
Joined: Sun Jun 29, 2003 7:32 pm
Location: Canada

Simple CGI help

Post 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? :)
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post 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.
Image Image
User avatar
griz
Enthusiast
Enthusiast
Posts: 167
Joined: Sun Jun 29, 2003 7:32 pm
Location: Canada

Post 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.
Post Reply