Skip to content

Commit 611cf13

Browse files
committed
commit src
1 parent efd1db8 commit 611cf13

File tree

8 files changed

+701
-0
lines changed

8 files changed

+701
-0
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
all: httpd
2+
3+
httpd: httpd.c
4+
gcc -W -Wall -lsocket -lpthread -o httpd httpd.c
5+
6+
clean:
7+
rm httpd

README

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
This software is copyright 1999 by J. David Blackstone. Permission
2+
is granted to redistribute and modify this software under the terms of
3+
the GNU General Public License, available at http://www.gnu.org/ .
4+
5+
If you use this software or examine the code, I would appreciate
6+
knowing and would be overjoyed to hear about it at
7+
jdavidb@sourceforge.net .
8+
9+
This software is not production quality. It comes with no warranty
10+
of any kind, not even an implied warranty of fitness for a particular
11+
purpose. I am not responsible for the damage that will likely result
12+
if you use this software on your computer system.
13+
14+
I wrote this webserver for an assignment in my networking class in
15+
1999. We were told that at a bare minimum the server had to serve
16+
pages, and told that we would get extra credit for doing "extras."
17+
Perl had introduced me to a whole lot of UNIX functionality (I learned
18+
sockets and fork from Perl!), and O'Reilly's lion book on UNIX system
19+
calls plus O'Reilly's books on CGI and writing web clients in Perl got
20+
me thinking and I realized I could make my webserver support CGI with
21+
little trouble.
22+
23+
Now, if you're a member of the Apache core group, you might not be
24+
impressed. But my professor was blown over. Try the color.cgi sample
25+
script and type in "chartreuse." Made me seem smarter than I am, at
26+
any rate. :)
27+
28+
Apache it's not. But I do hope that this program is a good
29+
educational tool for those interested in http/socket programming, as
30+
well as UNIX system calls. (There's some textbook uses of pipes,
31+
environment variables, forks, and so on.)
32+
33+
One last thing: if you look at my webserver or (are you out of
34+
mind?!?) use it, I would just be overjoyed to hear about it. Please
35+
email me. I probably won't really be releasing major updates, but if
36+
I help you learn something, I'd love to know!
37+
38+
Happy hacking!
39+
40+
J. David Blackstone

htdocs/README

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
These are sample CGI scripts and webpages for tinyhttpd. They can
2+
be redistributed under the terms of the GPL.
3+
4+
The most impressive demonstration I gave of tinyhttpd to my
5+
professor and my classmates was to load color.cgi with a value of
6+
"chartreuse." :) It's actually a very simple script, guys.
7+
8+
jdb

htdocs/check.cgi

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/local/bin/perl -Tw
2+
3+
use strict;
4+
use CGI;
5+
6+
my($cgi) = new CGI;
7+
8+
print $cgi->header('text/html');
9+
print $cgi->start_html(-title => "Example CGI script",
10+
-BGCOLOR => 'red');
11+
print $cgi->h1("CGI Example");
12+
print $cgi->p, "This is an example of CGI\n";
13+
print $cgi->p, "Parameters given to this script:\n";
14+
print "<UL>\n";
15+
foreach my $param ($cgi->param)
16+
{
17+
print "<LI>", "$param ", $cgi->param($param), "\n";
18+
}
19+
print "</UL>";
20+
print $cgi->end_html, "\n";

htdocs/color.cgi

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/local/bin/perl -Tw
2+
3+
use strict;
4+
use CGI;
5+
6+
my($cgi) = new CGI;
7+
8+
print $cgi->header;
9+
my($color) = "blue";
10+
$color = $cgi->param('color') if defined $cgi->param('color');
11+
12+
print $cgi->start_html(-title => uc($color),
13+
-BGCOLOR => $color);
14+
print $cgi->h1("This is $color");
15+
print $cgi->end_html;

htdocs/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<HTML>
2+
<TITLE>Index</TITLE>
3+
<BODY>
4+
<P>Welcome to J. David's webserver.
5+
<H1>CGI demo
6+
<FORM ACTION="color.cgi" METHOD="POST">
7+
Enter a color: <INPUT TYPE="text" NAME="color">
8+
<INPUT TYPE="submit">
9+
</FORM>
10+
</BODY>
11+
</HTML>

0 commit comments

Comments
 (0)