Winney 面向对象的 HTTP 请求
Tutorial
wy = Winney(host="www.baidu.com")
wy.add_url(method="get", uri="/", function_name="download")
wy.download()
t = wy.get_bytes()
print(t)
The Best Practice
from winney import Winney
from config import ZEUS_HOST, ZEUS_PORT, APP_TYPE, ZEUS_TOKEN_HEADER, ZEUS_TOKEN_VALUE
class Zeus(object):
def __init__(self, host, port):
self.winney = Winney(host=host, port=port, headers={ZEUS_TOKEN_HEADER: ZEUS_TOKEN_VALUE})
self.init_functions()
def init_functions(self):
self.winney.add_url(method="get", uri="/zeus/app_types/", function_name="get_types")
self.winney.add_url(method="get", uri="/zeus/app_types/{type_id}", function_name="get_type")
self.winney.add_url(method="get", uri="/zeus/accounts/{user_id}", function_name="get_user_info")
self.winney.add_url(method="get", uri="/zeus/application/{app_id}", function_name="get_app_info")
self.winney.add_url(method="get", uri="/zeus/applications/", function_name="get_apps")
def get_data(self, r):
if not r.ok():
return None
data = r.get_json()
if data["code"] != 0:
print("Failed to get zeus data, response = ", data)
return None
return data["data"]
def get_apps(self, user_id):
r = self.winney.get_apps(headers={"Authorization": "Token {}".format(user_id)}, user_id=user_id)
return self.get_data(r)
def get_types(self):
r = self.winney.get_types()
return self.get_data(r)
def get_type_by_id(self, type_id):
r = self.winney.get_type(type_id=type_id)
return self.get_data(r)
def get_user_info(self, user_id):
r = self.winney.get_user_info(user_id=user_id)
return self.get_data(r)
def get_app_info(self, app_id):
r = self.winney.get_app_info(app_id=app_id)
return self.get_data(r)
zeus = Zeus(host=ZEUS_HOST, port=ZEUS_PORT)
zeus.get_app_info("123456)
Metadata
Release files for winney-redis 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| winney-redis-0.1.3.tar.gz | 5.0 kB | Without provenance | Details for winney-redis-0.1.3.tar.gz |
Release files / winney-redis-0.1.3.tar.gz
| Download URL | winney-redis-0.1.3.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b899c53b6874d1e1a85c146ce67c9851f861078c547a46aa7b8ed42061af8590
|
|
BLAKE2b-256 checksum How to use checksums |
1e8ecf7c06349b26a0eb1cf7a8d66d53213bccc24e9d4d0cb426fd91a99f9f85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.5
|
Security for winney-redis 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.