Any executable can be run this way and it simply needs to return a valid HTML string.
But every web server has optimizations built in to speed up the execution of a url. That's likely where Sergey is coming from in his comment.
Imagine if you have a CGI process that takes 25 seconds to initialize, calculate the answer and then return. Then you start getting 100 hits a minute on that process... Your server performance is going to suffer tremendously.
To solve this problem, web servers will usually support DLLs as an extension for CGI scripts. You associate a file extension with the DLL, and that file and HTTP requests will be passed to a call in the DLL for processing.
Using this method, allows for pre-caching of the files, and pre-Loading DLLs. This saves quite a bit of time in handling requests.
To provide specific recommendations, we need to know what server you're using.