给Qt搭建一个简单的Json服务器用于软件调试

一. vscode+nodejs+npm安装

二. nodejs服务器开启

  1. 打开vscode - 终端 - 新建终端

  2. 进入json_server目录

    cd D:\json_server
    

  1. 运行启动命令, 启动json-server服务器

    npm run json:server
    

效果如下:

PS D:\json_server> npm run json:server

> jsonserver@1.0.0 json:server
> json-server --watch --host 0.0.0.0  --routes route.json db.json


  \{^_^}/ hi!

  Loading db.json
  Loading route.json
  Done

  Resources
  http://0.0.0.0:3000/regappid
  http://0.0.0.0:3000/gettoken
  http://0.0.0.0:3000/post_ats_info
  http://0.0.0.0:3000/post_fl_infos
  http://0.0.0.0:3000/post_ats_status
  http://0.0.0.0:3000/post_tos_info
  http://0.0.0.0:3000/post_urgent_cmd
  http://0.0.0.0:3000/pis

  Other routes
  /api/user/regappid -> /regappid
  /api/system/gettoken -> /gettoken
  /api/pis/post_ats_info -> /post_ats_info
  /api/pis/post_fl_infos -> /post_fl_infos
  /api/pis/post_ats_status -> /post_ats_status
  /api/pis/post_tos_info -> /post_tos_info
  /api/pis/post_urgent_cmd -> /post_urgent_cmd

  Home
  http://0.0.0.0:3000

  Type s + enter at any time to create a snapshot of the database
  Watching...

三. Qt项目运行

打开以下项目控制:

DEFINES += PROJECT_SHH1418_PLATFORM
../ui_qml/shanghai1418platform/init/qml.qrc

后端文件

platformshh1418setting      # 软件设置
httppisc                    # 协议解析
metroplatformmsg            # 存储数据

前端文件

5.4.4PostMan接口发送数据

posted @ 2024-04-29 22:32  技术不支持  阅读(1)  评论(0编辑  收藏  举报