[Gambas-user] CGI - Hello World

James Linden kodekrash at ...1...
Wed Nov 22 15:43:45 CET 2006


It just hit me that I don't know how much Gambas is doing internally...
The first line of this SUB would be required for a conforming HTTP response.

PUBLIC SUB Main()
   PRINT "HTTP/1.1 200 OK\r\n"
   PRINT "Connection: close\r\n"
   PRINT "Content-Type: text/html; charset=iso-8859-1\r\n"
   PRINT "\r\n"
   PRINT "Hello World!"
END

For more info, read RFC 2616 <http://www.faqs.org/rfcs/rfc2616.html>.
Also, try telnet'ing into a valid web server:

telnet gambas.sourceforge.net 80
 > HTTP/1.1 GET / <and hit enter twice>

-- James

James Linden wrote:
> Last I checked, HTTP headers use "\r\n", not "\n"... try
> 
> PUBLIC SUB Main()
>     PRINT "Content-type: text/html\r\n\r\n"
>     PRINT "Hello World!"
> END
> 
> Erwin Pogz wrote:
>> Ok, i made some changes on my code but still doesnt work.
>>  I did have a startup class.
>>
>> Heres my Code:
>>
>> ' Gambas module file
>>
>> PUBLIC SUB Main()
>>   PRINT "Content-type: text/html\n\n"
>>   PRINT "Hello World!"
>> END
>>
>> Still doesnt work so i changed to something like this
>>
>> ' Gambas module file
>>
>> PUBLIC SUB Main()
>>   Response.Begin
>>   PRINT "Hello World"
>>   Response.End
>> END
>>
>> Still have no luck.
>>
>>
>> .. What i did is compiling my code and make an executable file as ff.gambas
>>
>> if I run the ff.gambas using the console, it works fine. But when executed it as CGI using Apache. An error message is showing up:
>>
>> premature end of script headers: ff.gambas
>>
>>
>> The rest of my perl scrips works fine. Should I need some tweak
>> in my httpd configuration?
>>
>> I just upgraded my Gambas2 to 1.9.46a
>>
>>
>> Best regards,
>> Erwin
>>  
>> ---------------------------------
>> Sponsored Link
>>
>> $200,000 mortgage for $660/mo - 30/15 yr fixed, reduce debt, home equity -  Click now for info
>> -------------------------------------------------------------------------
>> Take Surveys. Earn Cash. Influence the Future of IT
>> Join SourceForge.net's Techsay panel and you'll get the chance to share your
>> opinions on IT & business topics through brief surveys - and earn cash
>> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>>
> 
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> 




More information about the User mailing list