Small micro-channel application development (f) - server

table of Contents

Set up a simple local server

You can now use VS Code, if not operating in the terminal

Netease micro-channel applet cloud API calls

Baidu network disk server to extract address:


Set up a simple local server

Create a new folder fuwu

Then enter cmd in the page directory, call up the terminal

Which then enter npm init -y (New package.json)

Now in fuwu folder appeared package.json files.

You can now use VS Code, if not operating in the terminal

The fuwu folder into the VS Code

Open the terminal mode fuwu

You need to download some dependencies

Use the command is

npm i express -s 

   Domestic Mirror

cnpm i  

Foreign Mirror

npm i 

Effect installation process is as follows:

In fuwu folder can have a file

In package.json also more than one code

You can now create a new file to fuwu app.js

App.js to add the code:

var express = require('express');
var app=express();
// 数据
var obj=[
    {
        name:"bbb",
        age:18
    },
    {
        name:"aaa",
        age:20
    }
]

app.get('/goodsList',function(req,res){
    res.json({
        dataList:obj
    })
})

app.get('/detail',function(req,res){
    res.json({
        msg:'ss'
    })
})
//服务器本地主机的数字
app.listen('188',function(){
    console.log("服务启动了。。。")
})

After this you can run the server

Input:

node .\app.js

running result:

In the browser you can also access the local server a

http://localhost:188/goodsList

 

Netease micro-channel applet cloud API calls

NetEase cloud API server

We first need a Netease cloud music server

Baidu network disk server to extract address:

Link: https: //pan.baidu.com/s/1jXqZfnqnNyBDRwMgQt0uvQ 
extraction code: m3f4 

In this open cmd page, then the following steps are 

1, Taobao mirroring, foreign server is slow, install CNPM
npm install -g CNPM --registry = HTTPS: //registry.npm.taobao.org


2, corresponding to the installation module
cnpm install

3, start the server
node app.js


4、访问
http://localhost:3000/toplist/detail

There are data on the success of

 

 

Guess you like

Origin blog.csdn.net/qq_36171287/article/details/94550735