No project description provided
Project description
对requests库的包装,在flask配置文件中配置base_url, auth, 转发user-agent等。第一次访问网址生成全局的session, 本次request结束后, 关闭此session。
安装
pip install flask-http-client
使用
First init:
from flask_http_client import HTTPClient http_client = HTTPClient() http_client.init_app(app)
API
和requests的API一致,需要注意的是 url = base_url + path,所以base_url和path需要自己做好处理。
params = {}
resp = http_client.request('GET', '/users/', params=params)
resp = http_client.get('/users', params=params)
配置项
可以在构造方法修改配置前缀,默认为 HTTP_CLIENT
http_client = HttpClient(config_prefix='YOUR_CONFIG_PREFIX')
配置项 |
说明 |
---|---|
HTTP_CLIENT_BASE_URL |
api的url_prefix |
HTTP_CLIENT_AUTH |
requests中的auth参数 |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flask_http_client-0.1.6.tar.gz
.
File metadata
- Download URL: flask_http_client-0.1.6.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 962429d5d40730ea89dd98a1272bcc74b5e804fcb751b78358602a34aab15bbc |
|
MD5 | 77991e3aa5257dc7da1b79505ad2234b |
|
BLAKE2b-256 | 1771921ecb5c84c12809ed7a71013cd678b12b6431f0bad28aeb07fd5e09c60b |
File details
Details for the file flask_http_client-0.1.6-py3-none-any.whl
.
File metadata
- Download URL: flask_http_client-0.1.6-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 882b02d07a486890ba892f1a74942405f7de2a85c9b1dad9613eb42cef411f62 |
|
MD5 | 19c904cf6dd10382ab480a42666d089b |
|
BLAKE2b-256 | e528263ec5958519268cbe6ab62b78d1ac609f83b8400eba94cc82a580b426d7 |