“密码的API。”

mypasswords-api的Python项目详细描述


https://travis-ci.org/toopy/mypasswords-api.svg?branch=master

密码的API。

安装

这个python项目需要python 3.6,否则pip安装应该 工作正常:

$ pip install mypasswords-api

用法

默认情况下,我们可以将服务器运行为python模块,如下所示:

$ mypasswords_api 127.0.0.1:8000
======== Running on http://127.0.0.1:8000 ========(Press CTRL+C to quit)

它将使用异步或uvloop启动一个aiohttp实例(如果 已安装),事件循环。

设置

要处理设置,我们使用简单设置组合行为。默认情况下 基本设置模块将尝试从当前环境中获取值:

$ MYPASSWORDS_PER_PAGE=100PG_HOST=localhost mypasswords_api 127.0.0.1:8000

API

创建

$ http POST http://127.0.0.1:8000/passwords login=toopy password=abcd1234 site=github.com
HTTP/1.1 201 Created
Content-Length: 110
Content-Type: application/json;charset=utf-8
Date: Sat, 09 Sep 201708:59:37 GMT
Server: Python/3.6 aiohttp/2.2.0
X-API-Version: 0.1.0.dev0

{"id": "0753c165-0400-4e1f-b79c-8998d4987daf",
    "login": "toopy",
    "password": "abcd1234",
    "site": "github.com"}

更新

$ http PUT http://127.0.0.1:8000/passwords/0753c165-0400-4e1f-b79c-8998d4987daf login=toopy password=1234abcd site=github.com
HTTP/1.1 200 OK
Content-Length: 76
Content-Type: application/json;charset=utf-8
Date: Sat, 09 Sep 201709:05:47 GMT
Server: Python/3.6 aiohttp/2.2.0
X-API-Version: 0.1.0.dev0

{"id": null,
    "login": "toopy",
    "password": "1234abcd",
    "site": "github.com"}

列表

$ http GET "http://127.0.0.1:8000/passwords?direction=desc&order_by=site&page1&per_page=2"
HTTP/1.1 200 OK
Content-Length: 212
Content-Type: application/json;charset=utf-8
Date: Sat, 09 Sep 201709:23:43 GMT
Server: Python/3.6 aiohttp/2.2.0
X-API-Version: 0.1.0.dev0
X-Next-Link: /passwords?direction=desc&order_by=site&page=1&per_page=2[{"id": "f4a59e0f-f1ff-4bc7-8757-203fc4b0aff7",
        "login": "toopy",
        "password": null,
        "site": "twitter.com"},
    {"id": "7ef3130f-7844-49c6-a46c-2f6960cae697",
        "login": "toopy",
        "password": null,
        "site": "slack.com"}]

获取

$ http GET http://127.0.0.1:8000/passwords/7ef3130f-7844-49c6-a46c-2f6960cae697
HTTP/1.1 200 OK
Content-Length: 109
Content-Type: application/json;charset=utf-8
Date: Sat, 09 Sep 201709:24:33 GMT
Server: Python/3.6 aiohttp/2.2.0
X-API-Version: 0.1.0.dev0

{"id": "7ef3130f-7844-49c6-a46c-2f6960cae697",
    "login": "toopy",
    "password": "1234abcd",
    "site": "slack.com"}

删除

$ http DELETE http://127.0.0.1:8000/passwords/7ef3130f-7844-49c6-a46c-2f6960cae697
HTTP/1.1 204 No Content
Content-Length: 2
Content-Type: application/json;charset=utf-8
Date: Sat, 09 Sep 201709:46:55 GMT
Server: Python/3.6 aiohttp/2.2.0
X-API-Version: 0.1.0.dev0

许可证

麻省理工学院许可证

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Android中的java Apache Velocity(“无法找到资源”)   在安卓 api 17中使用应用程序上下文膨胀视图时,java不能在安卓自定义toast的布局中使用material主题属性   java相当于Joda时间中的周中日   从我的应用程序中拍摄的java照片,保存在正确的文件夹中,但在图库中看不到   Java中无需分配返回值即可调用内存管理非void方法   java如何根据集合大小确定使用哪种方法   java有可能在ProjectReactor中有一个对多个订阅者提供独立背压支持的热发布服务器吗?   mysql在插入之前检查注册数据?JAVA   java如何防止注册后重定向到其他活动?   java如何仅当SWT视图在屏幕上滚动到时才加载它们?   java将类添加到Swing包结果是一个可见函数上的IllegaAccessError   如何按日期对查询结果进行排序(Jpa、Java集合)   多线程同步java中的持久性加载程序   JavaNIFI自定义orc处理器为类org提供NoClassDefFoundError。阿帕奇。hadoop。hdfs。分布式文件系统   java为什么我的for循环告诉我语法错误,插入“AssignmentOperator Expression”?   java在swing中点击按钮可以打开Jmenu吗?   lambda使用Java流将对象映射到多个对象   在OSX小牛上使用多个JDK的java   java检查上、下、数字、符号和空格