Re: EuCGI test

new topic     » goto parent     » topic index » view thread      » older message » newer message

At 05:27 AM 27-02-1999 , you wrote:
>Both URL's worked fine for me, and both were fast.  Mind you, it's 1:30
>in the morning, and everything on the internet is fast at this time of
>night =)
>
>The script worked great.  I'm curious, how exactly did you implement CGI
>with Euphoria?  I made an (admittedly cursory) attempt at it, just out
>of curiosity, with little success.
>
>Anyways, thanks,
>Greg

Thanks you for wasting your time on my experiment ;)

It's weird. www.dabersoft.xitami.net doesn't work for me!

Here's the actual code of the CGI I made. I bouded the program, but surely
there must be a way to make the server execute exw.exe + cgi.exw. It's
messy, but what did you expected for 15 min. of experimentation? Don't jump
on me Jiri about my "planification" :)

--*CODE START*--

object infile, outfile, username
sequence server_url, remote_addr, today
integer in, out, logfile

infile = getenv("CGI_STDIN")
if atom(infile) then
    abort(-1)
end if
infile = "..\\" &infile

outfile = getenv("CGI_STDOUT")
if atom(outfile) then
    abort(-1)
end if
outfile = "..\\" &outfile

in = open(infile,"r")
out = open(outfile, "a")

puts(out, "Content-type: text/html\n\n")
puts(out, "<html><head><title>EuCGI test result</title>\n")
puts(out, "<body bgcolor=\"Teal\">")
puts(out, "<font face=\"Verdana\" color=\"Navy\"><div align=\"center\"><hr>")

username = getenv("FORM_USERNAME")
if atom(username) then
    puts(out, "Error retriving username<br><br>")
    username = ""
else
    puts(out, "Thanks <font color=\"Black\">" & username & "</font> for
using this EuCGI!<br><br>")
end if

server_url = getenv("SERVER_URL")
remote_addr = getenv("REMOTE_ADDR")

puts(out, "Connected to " & server_url & " from " & remote_addr & "<br><br>")
puts(out, "<hr>STDIN contents:<br><br>")

infile = gets(in)
while sequence(infile) do
    puts(out, infile&"<br>")
    infile = gets(in)
end while

puts(out, "<br><br>Daniel Berstein<br><a


-- Update logfile
logfile = open("eucgi.txt", "a")
today = date()
printf(logfile,"%d-%d %d:%d:%d %s as %s\n",{today[2], today[3], today[4],
today[5], today[6], remote_addr, username})
close(logfile)

close(in)
close(out)

--*CODE END*--

Some of the enviormental variables may be specific to the Xitami webserver
I'm using... maybe not.
CGI_STDIN is the filename where the query strings are stored, but I got
them (username) using getenv() instead. CGI_STDOUT is the filename where
output should be send. It's important you open it for "a"ppend... I tried
with "w"rite and got an ugly error. I used those "..\" because the
webserver wasn't giving be an appropiate relative path to CGI_STDIN/OUT
files. FORM_USERNAME if the name of the input field where you input your
name. Xitami let's me get query strings from enviormental variables and/or
from the CGI_STDIN file. I was too lazy to parse CGI_STDIN so just used
getenv().

BTW you can get you own domain name at http://www.tzo.com . ie:
http://greg.tzo.com. It's free for 30 days, to keep the service you must
pay $25 per year.

Side note: David, did the code I posted helped with your text metrics problem?


Regards,
         Daniel  Berstein
         [daber at pair.com]

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu