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

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.6.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flask_http_client-0.1.6-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

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

Hashes for flask_http_client-0.1.6.tar.gz
Algorithm Hash digest
SHA256 962429d5d40730ea89dd98a1272bcc74b5e804fcb751b78358602a34aab15bbc
MD5 77991e3aa5257dc7da1b79505ad2234b
BLAKE2b-256 1771921ecb5c84c12809ed7a71013cd678b12b6431f0bad28aeb07fd5e09c60b

See more details on using hashes here.

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

Hashes for flask_http_client-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 882b02d07a486890ba892f1a74942405f7de2a85c9b1dad9613eb42cef411f62
MD5 19c904cf6dd10382ab480a42666d089b
BLAKE2b-256 e528263ec5958519268cbe6ab62b78d1ac609f83b8400eba94cc82a580b426d7

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.10

1 file

0.0.9

1 file

0.0.8

1 file

0.0.7

1 file

0.0.6

1 file

0.0.5

1 file

0.0.4

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page