上QQ阅读APP看书,第一时间看更新
Checkout view
The initial endpoint will be /checkout, whereby the customer requests to make a payment. We define the handler associated with a get handler to execute /checkout as follows:
var path = require("path");
app.use(express.static(path.join(__dirname + '/views')));
app.get('/checkout', function(req, res) {
res.sendFile(path.join(__dirname+'/views/index.html'));
});
If you're unfamiliar with Express, we defined here a callback function that behaves like middleware (https://expressjs.com/en/guide/using-middleware.html) to handle the /checkout route. We are using sendFile to make the server send a static index.html file from the views/ directory to the browser, when the user requests the /checkout path.