1 Star 0 Fork 1

changjayvee / lark

forked from Gitee 极速下载 / lark 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Lark is a RESTy interface for redis

https://api.travis-ci.org/voidfiles/lark.png

Lark is a python library that provides a generic method from transforming a HTTP request into a redis command. If you have heard of webdis this works in roughly the same way. It provides two main framework specific methods for Django, and Flask. Though it should be easy to fit Lark into any python web framework.

Features

  • Has a RESTy interface ie. POST for writes, GET for reads, and DELETE for, well, deletes
  • Automatic JSON serialization and deserialization for redis values
  • Automatic key prefixing for multi-user environments
  • Fully tested adapters for Flask and Django
  • Support for scope based authorization with an eye towards hooking up with flask-oauthlib
  • While rough, documentation is available for all supported methods

Quickstart

To get started make sure that you have redis installed, then install lark.

pip install lark

Next you can create a simple Flask app that mounts the lark blueprint. Lark also comes with a Redis middleware for setting up redis connections.

from flask import Flask
from lark.ext.flask.redis_api import redis_api_blueprint
from lark.ext.flask.flask_redis import Redis

app = Flask(__name__)
# Add a simple redis connection to the global object
Redis(app)

app.config['DEFAULT_LARK_SCOPES'] = set(['admin'])

# Mount the redis blueprint
app.register_blueprint(redis_api_blueprint, url_prefix='/api/0')


if __name__ == '__main__':
    app.run()

Now you can run the server and then you will be able to interact with the API like so. You can find documentation on all the calls here.

>>> curl http://127.0.0.1:5000/api/0/get/a/
{"meta": {"status": "ok", "status_code": 200}


>>> curl -X POST -H 'Content-Type: application/json' \
--data-ascii '{"value": "foo"}' \
http://127.0.0.1:5000/api/0/set/a/
"meta": {"status": "ok", "status_code": 200}, "data": true}

>>> curl http://127.0.0.1:5000/api/0/get/a/
{"meta": {"status": "ok", "status_code": 200}, "data": "foo"}

Planned Features

  • Flask middleware to support oauth2
  • A full Web interface for managing, and editing redis values.
MIT License Copyright (c) 2013 Alex Kessinger Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Lark 是一个 python 库,提供了将 HTTP 请求转换为 redis 命令的通用方法 展开 收起
Python
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/changjayvee/lark.git
git@gitee.com:changjayvee/lark.git
changjayvee
lark
lark
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891