简体   繁体   中英

How to call node.js as a local app?

I have an apache server running, i want to run a javascript code a user made with an input, then get back the response from node.js and store it in a database. Any idea on how to set this up? I don't want to use node.js as a webserver, just a javascript interpreter. Also, i don't want the script running forever waiting for events, i execute the script, get the response ( or write it to the db from node.js) and that's it, kill the process.

Just do the following from the CLI

$ node script.js input

Make sure the script can take CLI data, do its thing, and then terminate.

The output should be send directly to stdout. If you can't read from stdout just pipe to a file and read from the file

$ node script.js input > out.temp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM