Clask
Github:https://github.com/mouday/Clask
简介
Clask: a http client based on requests just like Flask
对比:
| - | 描述 | 运行环境 |
|---|---|---|
| Flask | 路由映射到方法 | 服务端 |
| Clask | 方法映射到路由 | 客户端 |
安装
pip install clask
使用示例
1、Flask作为服务器代码
# -*- coding: utf-8 -*-
from flask import Flask, jsonify
app = Flask(__name__)
@app.route("/get")
def get():
data = {
"name": "Tom",
"age":23
}
return jsonify(data)
if __name__ == '__main__':
app.run(debug=True)
2、Clask作为客户端的代码
# -*- coding: utf-8 -*-
from clask import Clask
api = Clask(base_url="http://127.0.0.1:5000")
# 发送get请求
@api.route("/get")
def get():
pass
if __name__ == '__main__':
get()
# '{"name": "Tom", "age": 23}'
其他示例
# 发送get请求
@api.get("/get")
def get():
pass
# 发送get请求
@api.post("/post")
def post():
pass
# 前置处理器
@api.before_request
def before_request(options):
print('before_request::', options)
return options
# 后置处理器
@api.after_request
def after_request(response):
print('after_request', response.status_code)
return response.json()
# 异常处理器
@api.error_handler
def error_handler(e):
print(e)
return None
Metadata
Release files for clask 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| clask-0.0.5.tar.gz | 5.2 kB | Without provenance | Details for clask-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| clask-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for clask-0.0.5-py3-none-any.whl |
Total release size: 12.0 kB
Release files / clask-0.0.5.tar.gz
| Download URL | clask-0.0.5.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
79b04e96ffcb1262b9f415c35dac1cbe90b6136a3f0003af3a4791df157bb963
|
|
BLAKE2b-256 checksum How to use checksums |
475937fe0e61efb377c4a65c8bc3669869b56ec246a9f36bffcd02332fd54999
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.0
|
Release files / clask-0.0.5-py3-none-any.whl
| Download URL | clask-0.0.5-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c86d4d7d238764e87143a6e73cc23a5cd5e053224c6f515715e0008e68da8525
|
|
BLAKE2b-256 checksum How to use checksums |
7f44b623adf5519dd39a2fdc4e76b054892c91e89aeedfc74af0d20fadaf2497
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.0
|
Security for clask 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.