所以,这是我第一次在windows中托管节点js应用程序。我已经能够成功托管节点应用程序并启动并运行我的服务器文件。但后来我想知道在托管之后如何导航到其他get / post请求。当我在我的IDE中进行操作时,一切都运行良好。但现在,当我尝试导航到其他获取请求时,我会继续获得相同的服务器日志。这就是我的服务器文件的样子。 -
server.js
var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var app = express();
var http = require('http');
var Flutterwave = require("flutterwave");
var flutterwave = new Flutterwave("******","*******");
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('Hello, world! [helloworld sample; iisnode version is ' + process.env.IISNODE_VERSION + ', node version is ' + process.version + ']');
}).listen(process.env.PORT);
/*
app.listen(3001, function (req,res) {
console.log('Example app listening on port 3000!')
});
*/
app.get("/",function (req,res) {
res.render("index",{'title':'helloworld'});
});
app.post('/pay', function (req, res) {
var jsonString = '';
var validateoption = req.body.validateoption;
var authmodel = req.body.authmodel;
var cardno = req.body.cardno;
var cvv = req.body.cvv;
var expirymonth = req.body.expirymonth;
var expiryyear = req.body.expiryyear;
console.log("Validateoption",req.body.validateoption);
flutterwave.Card.tokenize({
"validateoption":validateoption,
"authmodel":authmodel, /*Only NOAUTH and BVN are accepted*/
"bvn": "(Optional:Only needed where authmodel is BVN)",
"cardno":cardno,
"cvv":cvv,
"expirymonth":expirymonth,
"expiryyear":expiryyear
}, function(err,resp,body) {
console.log(resp.body.data);
res.json(resp.body.data);
});
});
IIS节点上的we.config文件 -
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
</system.webServer>
</configuration>
1. localhost/node/Fluterwave/server.js/pay
2. localhost/node/Fluterwave/server.js/
---他们给出了同样的信息Hello, world! [helloworld sample; iisnode version is 0.2.21, node version is v6.9.2]