后台想要测试自己的代码,但仅根据postman无法查看最终效果所以最好是在自己本地搭建一套前台环境nginx
Build rst 文件需要先安装斯芬克斯 开启虚拟环境
(snmp)pip install sphinx sphinx-rtd-theme
(snmp)pip install -r test-requirements.txt(PS:这个是build文件时安装的,另一个requirement文件是后台需要运行时安装)
(snmp)sphinx -build -W -b html docs/source docs/build
然后到对应目录下会看到下图的目录结构,在api.rst里把路径写上,snmp里就可以正常写sphinx
User
=============
创建user
---------------------------------------------------------------------------------
.. code-block:: sh
POST api/users
**参数说明**
====================== ============ ====== =================================================================
字段 类型 必需 描述
====================== ============ ====== =================================================================
``username`` string True 用户(用户名由字母、数字、下划线、 逗号、减号 组成, 长度为1-24位)
``password`` string True 密码(至少包含一个小写字母、大写字母、特殊符号和数字)
====================== ============ ====== =================================================================
**请求参数示例**
.. code-block:: json
{
"username": "lily",
"password": "123456",
}
**响应结果示例**
Http Code: 201
.. code-block:: json
{
"info": {},
"data": {
"id": "3fc2669e9e034c47844e885bb6b6d42a",
"created_on": "2019-01-22T19:43:40Z",
"updated_on": "2019-01-22T19:43:40Z",
"username": "lily",
"password": "pbkdf2:sha256:50000$bd128iIw$e8360cea3f538dde3ea3a4999ef1c70646d1c4c089c3428974cdb25505024805",
"visited_on": "2019-01-22T19:43:40Z"
}
}
安装nginx
1. setenforce 0
2. sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
3. sudo yum install -y nginx
#启动nginx,到服务器可以看到
4. sudo systemctl start nginx.service
5. cd /etc/nginx/
6. cat nginx.conf(如图)
7. cd /etc/nginx/conf.d/default.conf文件夹
8. vi default.conf更改默认内容,端口冲突,引用路径(pwd)
9. cp default.conf default.conf_bak 将默认的default文件重命名复制(忽略后缀)
10. vi default.conf 更改listen端口,和location绑定位置
#重新启动nginx,到服务器可以看到
11. sudo systemctl restart nginx.service
步骤6图片
步骤10修改listen的端口和location对应之前的build路径