Why not just run a webserver on your local machine and limit access to it by having it listen on 127.0.0.1? This would be a better solution for you especially if you want to use a CGI app. Web servers such as Apache and IIS have support built into them to support CGI apps in numerous languages. This would be a tedious task to emulate and anyway, why re-invent the wheel?