Home > Web Front-end > JS Tutorial > The construction process of local rapid test server based on Node.js

The construction process of local rapid test server based on Node.js

不言
Release: 2018-08-17 11:08:20
Original
1435 people have browsed it

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
Copy after login

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);
Copy after login

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);
Copy after login

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);
Copy after login

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, '*');
Copy after login

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, '*');
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template