__init__.py
This file
Path
requests/__init__.py
86 lines · 2.1 KiB · Python
Last changed by
v2.12.1Cory Benfieldbefore adoptioneb39a55
History of this fileTake it
1# -*- coding: utf-8 -*-23# __4# /__) _ _ _ _ _/ _5# / ( (- (/ (/ (- _) / _)6# /78"""9Requests HTTP library10~~~~~~~~~~~~~~~~~~~~~1112Requests is an HTTP library, written in Python, for human beings. Basic GET13usage:1415 >>> import requests16 >>> r = requests.get('https://www.python.org')17 >>> r.status_code18 20019 >>> 'Python is a programming language' in r.content20 True2122... or POST:2324 >>> payload = dict(key1='value1', key2='value2')25 >>> r = requests.post('http://httpbin.org/post', data=payload)26 >>> print(r.text)27 {28 ...29 "form": {30 "key2": "value2",31 "key1": "value1"32 },33 ...34 }3536The other HTTP methods are supported - see `requests.api`. Full documentation37is at <http://python-requests.org>.3839:copyright: (c) 2016 by Kenneth Reitz.40:license: Apache 2.0, see LICENSE for more details.41"""4243__title__ = 'requests'44__version__ = '2.12.1'45__build__ = 0x02120146__author__ = 'Kenneth Reitz'47__license__ = 'Apache 2.0'48__copyright__ = 'Copyright 2016 Kenneth Reitz'4950# Attempt to enable urllib3's SNI support, if possible51try:52 from .packages.urllib3.contrib import pyopenssl53 pyopenssl.inject_into_urllib3()54except ImportError:55 pass5657import warnings5859# urllib3's DependencyWarnings should be silenced.60from .packages.urllib3.exceptions import DependencyWarning61warnings.simplefilter('ignore', DependencyWarning)6263from . import utils64from .models import Request, Response, PreparedRequest65from .api import request, get, head, post, patch, put, delete, options66from .sessions import session, Session67from .status_codes import codes68from .exceptions import (69 RequestException, Timeout, URLRequired,70 TooManyRedirects, HTTPError, ConnectionError,71 FileModeWarning, ConnectTimeout, ReadTimeout72)7374# Set default logging handler to avoid "No handler found" warnings.75import logging76try: # Python 2.7+77 from logging import NullHandler78except ImportError:79 class NullHandler(logging.Handler):80 def emit(self, record):81 pass8283logging.getLogger(__name__).addHandler(NullHandler())8485# FileModeWarnings go off per the default.86warnings.simplefilter('default', FileModeWarning, append=True)