美文网首页
无标题文章

无标题文章

作者: kuixiang | 来源:发表于2017-02-21 18:32 被阅读0次

    api-doc-manager

    API文档管理工具:

    普通用户可以浏览API接口,管理员用户可以新增、删除、编辑API接口;

    可以实现接口名称、接口描述、接口参数、接口输出、接口调用方式、接口GET/POST实时验证、接口changelog等管理;

    工程基于flask,前端基于pure framework

    运行环境

    • python 2.7

    使用方式

    • 设置环境变量,开发/测试/生产分别为development/test/production

      export DOC_CENTER_PROFILE=test;
      
    • 安装python及相关类库(或运行setup.py)
      linux:

      先安装python-devel
      以CentOS为例:yum install python-devel
      

      安装程序运行的通用依赖库

      pip install requests Flask Flask-SQLAlchemy Flask-Script gunicorn gevent Pygments flask_assets beautifulsoup4
      

      另外还需要安装MySQLdb(依赖mysql-devel,如果系统中没有安装过mysql则需单独安装yum install mysql-devel)
      linux

      unzip MySQL-python-1.2.5.zip
      cd MySQL-python-1.2.5
      python setup.py install
      

      windows

      通过下面的链接下载安装(需要python的版本为2.7)
      http://www.codegood.com/archives/129
      
    • 修改数据库配置config.py

    • 运行manage.py初始化数据库

    • 本地直接运行runserver.py

    • 服务器部署

    cd /usr/local/api_doc(请cd到工程目录)
    python setup.py install
    gunicorn -c unicorn.py runserver:app &
    
    • 如果你打算使用nginx

    nginx可做如下设置:

    location ~* ^/doc {
        uwsgi_pass unix:/tmp/uwsgi.sock;
            include uwsgi_params;
        rewrite ^/doc(.*) http://xxx.xx.xx.xx:5000$1 last;
    }
    

    这样你就可以通过http://domain or xxxx.xx.xx.xx/doc访问了

    Changelog

    1. 新增管理员和普通用户管理,并分别赋予权限,管理员登陆后可以进行增删改查接口,接收用户反馈信息;普通用户登陆后可以关注接口更新,接收接口更新通知,提交接口问题等;
    2. 主题变更,好像更大气一点哦;
    3. 新增更多便捷操作。

    TODO

    1. 计划新增测试人员账号和权限管理;
    2. 计划新增接口提交管理;

    更新python及安装pip

    更新系统和开发工具集
    更新指令
    yum -y update
    yum groupinstall -y 'development tools'
    另外还需要安装 python 工具需要的额外软件包 SSL, bz2, zlib
    yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget
    源码安装Python 2.7.x
    wget http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz
    xz -d Python-2.7.8.tar.xz
    tar -xvf Python-2.7.8.tar
    安装详情:

    进入目录:

    cd Python-2.7.8

    运行配置 configure:

    ./configure --prefix=/usr/local

    编译安装:

    make
    make altinstall

    检查 Python 版本:

    [root@dbmasterxxx ~]# python2.7 -V
    Python 2.7.8
    设置 PATH
    为了我们能够方便的使用Python,我们需要设置系统变量或者建立 软连接将新版本的 Python
    加入到 path 对应的目录 :
    export PATH="/usr/local/bin:$PATH"
    or
    ln -s /usr/local/bin/python2.7 /usr/bin/python

    检查

    [root@dbmasterxxx ~]# python -V
    Python 2.7.8
    [root@dbmasterxxx ~]# which python
    /usr/bin/python
    安装 setuptools

    获取软件包

    wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz

    解压:

    tar -xvf setuptools-1.4.2.tar.gz
    cd setuptools-1.4.2

    使用 Python 2.7.8 安装 setuptools

    python2.7 setup.py install
    安装 PIP
    curl https://bootstrap.pypa.io/get-pip.py | python2.7 -

    修改pip源

    国内pypi源
    https://pypi.mirrors.ustc.edu.cn/simple/
    http://mirrors.aliyun.com/pypi/simple/
    http://pypi.v2ex.com/simple
    http://pypi.douban.com/
    修改pip默认源
    $ cat .pip/pip.conf
    [global]
    trusted-host = mirrors.aliyun.com
    index-url = http://mirrors.aliyun.com/pypi/simple/
    如果使用阿里云主机,请用下面的地址: index-url = http://mirrors.aliyuncs.com/pypi/simple/

    不加trusted-host会报下面的警告:

    The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with ‘—trusted-host mirrors.aliyun.com’.

    相关文章

      网友评论

          本文标题:无标题文章

          本文链接:https://www.haomeiwen.com/subject/pubuwttx.html