How do I access a node.js server from the command line

综合技术 2017-12-03

Background to this problem:

I am using FFmpeg to convert videos - it is working fine. I am sending the FFmpeg requests to the command line using exec() in PHP. I am also using node.js and to deliver real time updates to my users- this is also working fine. I would like to be able to send a real time alert when the video has completed its conversion.

My question is:

How do I send a request from the command line to my node server. Can I run a JS file from the command line? If not what is the best way round it?

Thank you for your advice,


I would go for curl. Trigger node with curl.

Something like:

curl localhost:3000/encodingCompleted?user=abc&[email protected]

And now node knows "completed" and can send a realtime update back to the user.

Hello, buddy!

责编内容by:Hello, buddy! (源链)。感谢您的支持!


Never Use Naked If Statements For C, PHP, Java and Javascript programmers, naked if-statements are code landmines. March 23...
一文了解 2018 年最值得关注的 12 大框架... 【CSDN编者按】如今的 IT 领域对开发者要求越来越高,对各种框架的掌握变得非常重要,掌握多种框架可以让开发者快速开发原型和实际项目。本文将列举 12 个适合移动开发者以及 Web 开发者的框架,并...
在 JavaScript 中如何实现深拷贝? As we know,在 JavaScript 中,对象是以 引用 的形式存储在一个变量中的,我们使用这样的变量进行赋值实际上复制的只是这个对象的引用,如果我们想真正完全地复制一个对象,这种操...
不用正则表达式,用javascript从零写一个模板引擎(一)... 模板引擎的作用就是将模板渲染成html, html = render(template,data) ,常见的js模板引擎有Pug,Nunjucks,Mustache等。网上一些制作模板引擎的文章大部...
ExVenture Update November 2017 The last month for ExVenture has seen mostly metrics improvements and some client additions. There ...