Skip to main content

HTTP client extension for Flask.

Project description

对requests库的包装,在flask配置文件中配置base_url, HttpBasicAuth, verify等。

安装

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 = AuthClient(config_prefix='YOUR_CONFIG_PREFIX')
配置项 说明
HTTP_CLIENT_BASE_URL api的url_prefix
HTTP_CLIENT_USERNAME BasicAuth的username
HTTP_CLIENT_PASSWORD BasicAuth的password
HTTP_CLIENT_VERIFY requests的verfy配置,可以是自定义证书的路径

Project details


Download files

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

Files for flask-http-client, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size flask-http-client-0.0.4.tar.gz (2.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page