You can configure Apache to treat some files as
CGI executables [1], which get invoked by their file path, read http requests on their standard in, and print http responses on their standard out. It's how most of "Web 1.0" was built, and it supports streaming in a way that most MVC frameworks don't.
Sometimes if you haven't got things configured properly, you do return the script as text rather than the output of the script.
The old school default was to put executable in the cgi-bin folder (wherever that had been configured to be) and make them executable. That would run the script and return the output.
Or if my questions aren't making sense, that would be good to know as well.