Thursday, April 29, 2010

The Mongoose and the CGI

Yeah yeah....didn't post in a long time. Don't blame me, blame my TiVo. I upgraded the hard drive and now my TV viewing is backing up and taking up a huge portion of my free time.

Anyway, a quick post on some things I found while working on a project. I needed a small light weight web server that was written in C. A quick google and I found mongoose. Small, lightweight, written in C, and open source to boot. Love that Internet.
I haven't played with mongoose too much yet. I'm planning to do a bit of coding with it to create and setup a custom web server. But that will start later on. For the same project, I also needed to run a bunch of CGI scripts. So I thought that maybe mongoose would be able to do it and after fiddling around a bit, it worked perfectly. If you are in a need of a quick web server...do check out mongoose. It's worked perfectly so far. I'll post more about it once I get into the programming for it.

So about the CGI...I've always thought of CGI scripts as some sort of ghetto code that people used before Java. CGIs were everywhere when I started out as a programmer and I remember reading a lot of articles saying how CGIs were bad and J2EE was the new and better way to go. So in the back of my head I always thought of CGIs a some lame thing.

The CGI script I needed to run was written in C and did a simple database lookup, read in a graphic image file, extracted a portion of the image, did some scaling and positioning of the image, and sent it all back with additional meta data. Sure, you can do the same thing with Java or probably a ton of other languages, but who would have thought a CGI could do that. I guess I should have but I underestimated what a CGI could do and in this case, it was a simple, elegant solution to address what this project needed.

So the moral of the story is, look for the cool new thing to help you accomplish what you need to do, but don't forget the tried and true methods, and especially do not disregard something without fully understanding what it is and what it can do.