The content of this article is about the construction process of a local rapid test server based on Node.js. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
local-web-test
A local node.js-based test server
Supports fast startup of web container services
Supports fast sending Get, post requests are recorded in the /log folder and output on the console
Support a function to complete cors cross-domain requests
Install
npm install --save local-web-test
Usage
Create a local static server
The first parameter is the static file address, and the second parameter is the port number
eg;
var test = require('local-web-test'); test.static('./', 3344);
Create a get request
The get request is printed on the console and written to the file./log/data.js
The first parameter is the url. The second parameter is the port number
eg;
var test = require('local-web-test'); test.get('./', 3344);
Create a post request
Print the post request
The first parameter is the post address, The two parameters are port numbers. The read JSON data will be output to the console and written to the file. The file path is ./log/data.json
eg
var test = require('local-web-test'); test.post('./', 3344);
Cors
Create a get Cors request
The get request is printed on the console and written to the file ./log/data.js
The first one The parameter is the get address. The second parameter is the port number. The read JSON data will be output to the console and written to the file. The file path is log/data.json. The third parameter is the cors domain name. The default Support sending cookies
eg:
var test = require('local-web-test'); test.getCors('./', 3344, '*');
Create post request
Print post request
The first parameter is the post address, and the second parameter is The port number will output the read JSON data to the console and write it to the file. The file path is ./log/data.json. The third parameter is the cors domain name
eg
var test = require('local-web-test'); test.post('./', 3344, '*');
Dependency: This package depends on body-parser cookie-parser express multer; package address: https://www.npmjs.com/package...
github: https://github.com/mySoul8012 ...
Related recommendations:
detailed explanation of creating a local server with node.js
Related to local test PHP connection to remote server Question
node.js connects to mongoDB database to quickly build your own web service_node.js
The above is the detailed content of The construction process of local rapid test server based on Node.js. For more information, please follow other related articles on the PHP Chinese website!