Javascript 简单的Hello World节点服务器问题
我正在尝试制作一个简单的NodeACS应用程序,在这个应用程序中,我希望从cURL接收一些xml格式的数据,并在NodeACS应用程序中,在接收到这些数据后,我希望向客户端发送响应 我的系统配置为:Javascript 简单的Hello World节点服务器问题,javascript,node.js,curl,jenkins,titanium,Javascript,Node.js,Curl,Jenkins,Titanium,我正在尝试制作一个简单的NodeACS应用程序,在这个应用程序中,我希望从cURL接收一些xml格式的数据,并在NodeACS应用程序中,在接收到这些数据后,我希望向客户端发送响应 我的系统配置为: function index(req, res) { console.log(req.headers); req.on('data', function (data) { console.log("Data received successfully"); }
function index(req, res) {
console.log(req.headers);
req.on('data', function (data) {
console.log("Data received successfully");
});
req.on('end', function () {
res.writeHead(200);
res.end();
});
}
{
"routes":
[
{ "path": "/", "method":"POST", "callback": "application#index" }
],
"filters":
[
{ "path": "/", "callback": "" }
],
"websockets":
[
{ "event": "", "callback": ""}
]
}
节点v0.10.13(x86)
钛SDK版本:钛工作室,版本:3.4.0.201409261227版本:jenkins-Titanium-rcp-master-197(源代码/主代码)
操作系统:Windows 7 64位
以下是我的代码文件:
application.js:
function index(req, res) {
console.log(req.headers);
req.on('data', function (data) {
console.log("Data received successfully");
});
req.on('end', function () {
res.writeHead(200);
res.end();
});
}
{
"routes":
[
{ "path": "/", "method":"POST", "callback": "application#index" }
],
"filters":
[
{ "path": "/", "callback": "" }
],
"websockets":
[
{ "event": "", "callback": ""}
]
}
config.json:
function index(req, res) {
console.log(req.headers);
req.on('data', function (data) {
console.log("Data received successfully");
});
req.on('end', function () {
res.writeHead(200);
res.end();
});
}
{
"routes":
[
{ "path": "/", "method":"POST", "callback": "application#index" }
],
"filters":
[
{ "path": "/", "callback": "" }
],
"websockets":
[
{ "event": "", "callback": ""}
]
}
我正在命令提示符下运行代码,如下所示:
acs运行——端口7788
我没有在任何其他文件中进行任何更改。问题是当我试图使用以下命令通过curl发布XML数据时:
curl-xpost-d@output.xmlhttp://localhost:7788/
然后,控制台中只打印标题,如下所示:
D:\GMON-Server\GMON-Server>acs run --port 7788
ACS: Appcelerator Cloud Services Command-Line Interface, version 1.0.20
Copyright (c) 2012-2014, Appcelerator, Inc. All Rights Reserved.
[INFO] No dependencies detected
[INFO] socket.io started
[INFO] ACS started on port 7788
[INFO] { 'user-agent': 'curl/7.39.0',
host: 'localhost:7788',
accept: '*/*',
'content-length': '55580',
'content-type': 'application/x-www-form-urlencoded',
expect: '100-continue' }
并且req.on('data')事件和req.on('end')事件都没有触发
请告诉我是否有任何配置问题或我的代码有问题