Re: Running CGI scripts without a server
by thezip (Vicar) on Apr 02, 2003 at 05:46 UTC
|
Why not just run a webserver on your PC?
Apache is a dandy one that runs on virtually every platform...
Where do you want *them* to go today?
| [reply] |
|
|
Well, I installed the Apache package, but I'm not really sure how to use it without giving it a security certificate and all that. I know so little about servers, so there's probably something I'm missing. If someone can steer me towards a good Apache tutorial, I'd certainly be appreciative.
| [reply] |
|
|
You won't need a cert.
Everything you'll need to configure is in httpd.conf. I run Windows 98, so mine is in "C:\Program Files\Apache Group\Apache\conf\httpd.conf".
There are excellent docs with the Apache package, but I've always thought httpd.conf is very straight-forward. Just make a backup of it in case you screw something up.
You could also just use the default directories --
- C:\Program Files\Apache Group\Apache\htdocs
- C:\Program Files\Apache Group\Apache\cgi-bin
You'll need to put your scripts in the cgi-bin directory...
Where do you want *them* to go today?
| [reply] |
Re: Running CGI scripts without a server
by zby (Vicar) on Apr 02, 2003 at 07:50 UTC
|
| [reply] |
Re: Running CGI scripts without a server
by PodMaster (Abbot) on Apr 02, 2003 at 05:44 UTC
|
Yeah, sure, here's an example from my harddrive
E:\dev\LOOSE>perl pod.wiki.cgi
Title: index
Content-Type: text/html; charset=ISO-8859-1
<html><head><title>index</title></head><body><table width='100%'><tr><
+td><table width='100%'><tr><td align='left'><a href='/pod.wiki.cgi/di
+s
play/AllNodes'>AllNodes</a></td><td align='center'>CGI::Wiki::Simple W
+iki</td><td align='right'><form method=post action='/pod.wiki.cgi'><i
+n
put type='text' name='node' /><input type='hidden' name='action' value
+='display' /><input type='submit' value='go' /></form></td></tr></tab
+l
e>index</td></tr></table><hr /><p>Welcome to a CGI::Wiki::Simple wiki.
+</p>
<p>The current formatter is <b>CGI::Wiki::Formatter::Default</b></p>
<p>There are no <em>implicit</em> links,only <strong>explicit</strong>
+ ones (as in <TT>[<a href="/pod.wiki.cgi/display/link%20text">lin
+k
text</a>]</TT> or <TT>[<a href="/pod.wiki.cgi/display/link">t
+itle</a>]</TT>)</p>
<p>Newlines are taken litelarlly (all lines are wrapped in like <em>&l
+t;p>this</p></em>).</p>
<p>Two single quotes make enclosed text italicized like <em>" thi
+s "</em> (you can safely say Rock'n'Roll)</p>
<p>Dis<boy>allowed</boy> html <SCRIPT>disallowed htm
+l</script> <boy><girl></boy></girl></p>
<p><pre>Pre tags are allowed</pre></p>
<hr /><a href='/pod.wiki.cgi/preview/index'>edit</a>
<center>
<form method=post action='http://dev.localhost/LOOSE/pod.wiki.cgi'>
<a href='http://dev.localhost/LOOSE/pod.wiki.cgi/display/index'>home</
+a>
| Powered by <a href='http://search.cpan.org/search?mode=module&query=
+CGI::Wiki'>CGI::Wiki</a>::<a href='http://www.corion.net/cgi-bin/wiki
+.
cgi/display/CGI%3A%3AWiki%3A%3ASimple'>Simple</a>
| <input type='text' name='node' />
<input type='hidden' name='action' value='display' />
<input type='submit' value='go' />
</form>
</center>
E:\dev\LOOSE>
See, it runs just fine. Web browsers only speak HTTP (you know what I mean) and that means you need a web server your browser can talk to, which in turn executes the CGI scripts for you. Apache is very nice, and there is always HTTP::Daemon (there is also chromatics Jellybean).
MJD says you
can't just make shit up and expect the computer to know what you mean, retardo!
I run a Win32 PPM
repository for perl 5.6x+5.8x. I take requests.
** The Third rule of perl club is a statement of fact: pod is sexy.
|
| [reply] [d/l] |
Re: Running CGI scripts without a server
by CountZero (Bishop) on Apr 02, 2003 at 15:23 UTC
|
If you remember that your "CGI script" is just another fancy word for a Perl program, you will understand that you can just execute your Perl program (either on the command line or through a dedicated editor (Komodo springs to mind as it has a special feature to allow easy feeding of your script with CGI parameters) and see its output. If the output if HTML, some editors can capture it and render it as a browser would do (again (Komodo is able to do so). CountZero "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
| [reply] |
Re: Running CGI scripts without a server
by thoglette (Scribe) on Apr 02, 2003 at 23:22 UTC
|
| [reply] |
Re: Running CGI scripts without a server
by iburrell (Chaplain) on Apr 03, 2003 at 17:42 UTC
|
Other people suggested setting up a local web server. This is probably the best way to develop CGI scripts because it mimics how it will run on a real web site. You won't be surprised by differences between development and production environments when you deploy it.
It is possible to run CGI scripts from the command line. This is very useful for a quick test. You can capture the output, and display the HTML file in a browser. Doing this for multiple pages or interaction will be a really slow process. And there are some things like cookies that won't work right. For example, the HTTP headers will show up at the top of the page unless you remove them in an editor.
perl script.cgi > script.html
| [reply] [d/l] |
Re: Running CGI scripts without a server
by Anonymous Monk on Apr 03, 2003 at 21:19 UTC
|
Download xitami from http://www.xitami.com and run it locally - it works like a dream. | [reply] |
| A reply falls below the community's threshold of quality. You may see it by logging in. |