1. Euphoria CGI Interface

Problem solved: Here's what works for me.

First: a simple form to post:
-------------------------------------
<HEAD><TITLE>CGI Demo</TITLE></HEAD>

<HR>HELLO

<P><FORM METHOD="POST"
ACTION="../cgi-dos/cmd.bat">

<P><B>Employee Locator</B>
rch on <SELECT NAME="what">
<OPTION SELECTED>Name
<OPTION>Title
<OPTION>Department
<OPTION>Location
</SELECT>

<P>which <SELECT NAME="how">
<OPTION SELECTED>starts with
<OPTION>contains
<OPTION>is exactly
<OPTION>sounds like
</SELECT>

<P>the following: <INPUT TYPE="text" NAME="value"><P>
<INPUT TYPE="checkbox" NAME="usecase" VALUE="yes">Case-sensitive<P>
<INPUT TYPE="submit" VALUE="Start Search">
</FORM>

<HR>
-------------------------------------------------------------
Now, a bat file to call the Eu program:
(This is cmd.bat)

rem pause to debug
ex c:/httpd/cgi-dos/cmd.ex %output_file% %CONTENT_FILE%
rem pause to debug
-----------------------------------------------------
Last, the Euphoria code: (cmd.ex)

-- Euphoria CGI
include get.e -- for waitkey pause while debugging

object cmdline, data, fn
  data = ""
  cmdline = command_line()

fn = open(cmdline[4],"r") -- read in the data stored in a temp file
if fn > 0 then                   -- by the server.
  data = gets(fn)
  close(fn)
end if
puts(1,data)

fn = open(cmdline[3],"w")   -- The output filename
if fn > 0 then                      -- is read by the server
  puts(1,"Writing output to:"&cmdline[3]&"\n") -- debug
  -- use the following line for plain text
  -- and remove all the html stuff
  -- puts(fn,"Content-type:text/plain\n")
  puts(fn,"Content-type:text/html\n")
  puts(fn,"\n")
  puts(fn,"<HTML><HEAD><TITLE>")
  puts(fn,"Euphoria CGI Results")
  puts(fn,"</TITLE></HEAD><BODY>")
  puts(fn,"<H1>Euphoria sez</H1>\n")
  puts(fn,"Your form data:")
  puts(fn,"<H5>")
  puts(fn,data)
  close(fn)
end if
-- uncomment wait to debug
--fn = wait_key()
-------------------------------------------------
Naturally, you can make the euphoria code do whatever
you want, and return either plain text or a full html page.
Whew!

Irv


------------------------------------------------------
Visit my Euphoria programming web site:
http://www.mindspring.com/~mountains
------------------------------------------------------

new topic     » topic index » view message » categorize

2. Re: Euphoria CGI Interface

>Problem solved: Here's what works for me.


Great Irv!
I'll test it soon.

What HTTP server are you using?

Regards,

    Daniel Berstein.

new topic     » goto parent     » topic index » view message » categorize

3. Re: Euphoria CGI Interface

At 07:51 PM 3/25/98 -0400, Daniel Berstein. wrote:
>>Problem solved: Here's what works for me.
>
>Great Irv!
>I'll test it soon.
>
>What HTTP server are you using?
>
Windows HTTPD -- it's got a *HUGE* set of web pages describing
various CGI and web interface questions. It's free, but I had some
trouble locating it, so I have posted the code on my web site for
anyone who needs it. whttpd14.zip, about 666k

Web servers write their data to a set of environment variables, (along
with the name of an input an output file, usually in the temp directory)
which you have to write to, then the server gets the data back from
the output file and sends it back to requestor. For some reason,
Euphoria can't find the environment variables, but a batch (.bat) file
can. Therefore, you use the batch file to pass the particular variables
you are interested in to Euphoria, and Euphoria writes to the output
file.
>
Irv

new topic     » goto parent     » topic index » view message » categorize

4. Re: Euphoria CGI Interface

At 09:06 AM 3/25/98 -0500, I wrote:

>Web servers write their data to a set of environment variables,
>For some reason,
>Euphoria can't find the environment variables,
<snip>

I was wrong. Euphoria can find the variables easily.
You can bind your CGI program and call it directly, or
can set up a batch file to call an .EX file, so you don't
have to bind every CGI prog (still plenty fast!)

I am posting the complete CGI code to my web page
if anyone wants them.

Irv
------------------------------------------------------
Visit my Euphoria programming web site:
http://www.mindspring.com/~mountains
------------------------------------------------------

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu