Skip to main content

对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参数

Metadata

Release files for flask-http-client 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flask-http-client 0.1.6
File Size Uploaded
flask_http_client-0.1.6.tar.gz 3.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flask-http-client 0.1.6
File Interpreter ABI Platform
flask_http_client-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 6.6 kB

Release files / flask_http_client-0.1.6.tar.gz

Download URL flask_http_client-0.1.6.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
962429d5d40730ea89dd98a1272bcc74b5e804fcb751b78358602a34aab15bbc
BLAKE2b-256 checksum
How to use checksums
1771921ecb5c84c12809ed7a71013cd678b12b6431f0bad28aeb07fd5e09c60b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Darwin/21.6.0

Release files / flask_http_client-0.1.6-py3-none-any.whl

Download URL flask_http_client-0.1.6-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
882b02d07a486890ba892f1a74942405f7de2a85c9b1dad9613eb42cef411f62
BLAKE2b-256 checksum
How to use checksums
e528263ec5958519268cbe6ab62b78d1ac609f83b8400eba94cc82a580b426d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Darwin/21.6.0

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.10

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page