Re: to Daniel: about CGI

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

At 11:12 PM 01-03-1999 , you wrote:
>Daniel,
>
>Cool CGI.  I didn't visit, but I get the idea from the code.  When I have
>some time, I play with the HTTP server you mentioned.  Some questions:

Come and visit me, you're invited :P

>1.  What do you need besides the HTTP server?  My ISP doesn't support CGI,
>but I have a webpage.  What does your CGI URL refer to?  I mean, how did
>you get this URL?

You only need the HTTP server. You don't even need to be connected to the
web! In fact I start experimenting with webserver and CGIs (offline)
because a client may need me to build a web database for him. I just wanted
to be prepared... and it's fun too ;)

Two short steps to run your own webserver offline:

1) Download and install (and configure if required) Xitami
(www.xitami.net), Sambar (www.sambar.com) or whatever webserver you like
(I've tested the first two succesfully), www.serverwatch.com is a good
place to find free comercial grade servers (while we wait for EuServer HTTP
edition).

2) Point your browser to http://127.0.0.1/ or http://localhost/
If the above fails set your proxy configuration to omit local addresses.
127.0.0.1 is know as the "loopback" IP and isn't assigned to any public
machine, it's a way to say "Me, myself".

If you are like me with a dial-up PPP internet connection, you get a
different IP address for your machine each time you connect. For others to
find your webserver they need to know a) The IP number you are currrently
using, or b) a domain name that is translated by a DNS (domain name
server?) server to your IP number.

So if your current IP is (i.e) 208.141.103.114 then anyone can point their
browser to http://208.141.103.114/ and get to you (that is also true for
Ftp, Telnet, etc.). To "publish" your current IP to others so they can
"visit" you is the problem. One way is to phone call all your friends
(fairly unpracticable since you are already using the phone line), or
submit a webpage (i.e. online.html) to your ISP account where you put "My
current IP is <a href="http://xxx.xxx.xxx.xxx"> xxx.xxx.xxx.xxx </a>" and
before diconnecting "I'm offline now".


Another alternative (b) is to take use of DNS servers. Each time you type
"www.zzzzz.com" on your browser the request is handled to your ISP DNS
server that must "translate" that text name to a valid IP number. He does
the job by quering a database. There are large domain name databases around
the world that are always updating themselfs (new sites are added, deleted,
changed IP all of the time). TZO (www.tzo.com) is one of them. They provide
a very nice service: Each time you connect to internet a small application
on your PC connect to TZO and tells them your current IP address, on the
fly the database is updated and your site is reachable as
yoursitename.tzo.com (xxxx.xitami.net is a colaborative effort of tzo and
xitami). The service is free for 30 days and then you must pay about
$25/year if you want to keep it.

About my small EuCGI. The CGI is run on MY computer, not on the ISP's one
or a web presece provider... I can see my CPU working (really it's
unnoticable for such low-low traffic). I can do this because the website is
run on my computer (see above explanation). Some ISP and webserver
providers let's you run CGIs on your account, but they are usually confined
to the CGI they own (mainly counters and email submitions), or if you are
lucky they must be done on C, Perl or shell scripts... in order to run an
Euphoria CGI they should be running Euphoria, wich as we all know doesn't
run yet on Unix, Linux or FreeBSD (most common "web" OSes).

>2.  Seems that the form value pairs are environment variables, is this
>correct?

On your HTML page you set your form:

<form action="http://mysite/cgi-bin/mycgi" method="POST">
        <input type="Text" name="USERNAME">
        <input type="Text" name="COUNTRY">
        <input type="Submit">
</form>

'action' tells the browser where to send the form on submision. Each
'input' field has a 'name' and 'value' property. So if the user enters
"Daniel Berstein" and "Chile" on the text fields and then press submit,
'mycgi' will recieve as it's query string:

USERNAME=Daniel+Berstein&COUNTRY=Chile

This query string can always (CGI standard) be obtained from the standard
input and your CGI should parse to get the appropiate valued of each item.
As I mentioned on other posts, Xitami (and probably most of Wintel
webservers, or even on ALL webserver... can't tell you) does the job for me
and sets one enviormental variable for each input field of the form. In
Xitami you can configure the prefix of this enviormental variables (I have
it as default: 'FORM_'), so I can read the values as:

sequence name, country  --Should be object, this is just an example

name=getenv("FORM_USERNAME")
country=getenv("FORM_COUNTRY")


You'll see on a previous post some CGI related links... go there!

>This is pretty cool!

Thanks :)


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