zoukankan      html  css  js  c++  java
  • 零代码搭建RESTful server

    json-server是一个基于nodejs的超轻巧RESTful server,可供前端人员在后台接口还没有开发完毕的时候进行模拟开发,简单介绍一下上手步骤,更多的调用方式和使用说明参见github

    1.安装node环境。

    2.安装json-server(直接安装到全局环境了,原谅我这么简单粗暴。。)

    npm install json-server -g
    

    3.新建数据文件d: est.json

    {
      "posts": [
        {
          "id": 1,
          "title": "json-server",
          "author": "typicode"
        }
      ],
      "comments": [
        {
          "id": 1,
          "body": "some comment",
          "postId": 1
        }
      ],
      "profile": {
        "name": "typicode"
      }
    }
    

     4.启动server监听http请求

    json-server --watch d:	est.json
    

     5.测试在浏览器输入http://localhost:3000/posts/1,返回内容如下:

    {
      "id": 1,
      "title": "json-server",
      "author": "typicode"
    }
    
  • 相关阅读:
    HDU 6043
    HDU 6033
    HDU 6041
    HDU 6050
    HDU 6053
    HDU 6055
    HDU 6045
    HDU 6044
    HDU 6040
    ZUFE 1035 字符宽度编码(字符串)
  • 原文地址:https://www.cnblogs.com/iamppz/p/4740210.html
Copyright © 2011-2022 走看看