Reputation: 496
I managed to configure my Apache to run cgi scripts and I tried to use javascript to generate output.
#!C:\php\php.exe
<script>
document.write("Hello world!");
</script>
However this only sends the contents and the document.write
is run on the client. I'd like to send Hello world! by javascript.
I know there is nodejs. I wonder if there is a module for Apache or some settings that enables running javascript on the server and send only the contents of document.write
?
Upvotes: 1
Views: 1315
Reputation: 943981
CGI explicitly spawns an external process, so would use mod_cgi
. You could then spawn a Node.js process.
You would, however, need to write a real CGI program and not use a fragment of HTML with embedded JS that depends on browser APIs.
#!/usr/bin/env node
process.stdout.write("Content-Type: text/plain\r\n\r\n");
process.stdout.write("Hello, world");
CGI isn't very efficient, and Node would be an odd choice of language. If you need to go via Apache then it would usually make more sense to run a server using Node and then use mod_proxy to access it via Apache.
Upvotes: 1