Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask-http-client-0.1.1.tar.gz (3.6 kB view hashes)

Uploaded source

Built Distribution

flask_http_client-0.1.1-py3-none-any.whl (3.7 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page