__init__.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # -*- coding: utf-8 -*-
  2. # __
  3. # /__) _ _ _ _ _/ _
  4. # / ( (- (/ (/ (- _) / _)
  5. # /
  6. """
  7. requests HTTP library
  8. ~~~~~~~~~~~~~~~~~~~~~
  9. Requests is an HTTP library, written in Python, for human beings. Basic GET
  10. usage:
  11. >>> import requests
  12. >>> r = requests.get('https://www.python.org')
  13. >>> r.status_code
  14. 200
  15. >>> 'Python is a programming language' in r.content
  16. True
  17. ... or POST:
  18. >>> payload = dict(key1='value1', key2='value2')
  19. >>> r = requests.post('http://httpbin.org/post', data=payload)
  20. >>> print(r.text)
  21. {
  22. ...
  23. "form": {
  24. "key2": "value2",
  25. "key1": "value1"
  26. },
  27. ...
  28. }
  29. The other HTTP methods are supported - see `requests.api`. Full documentation
  30. is at <http://python-requests.org>.
  31. :copyright: (c) 2015 by Kenneth Reitz.
  32. :license: Apache 2.0, see LICENSE for more details.
  33. """
  34. __title__ = 'requests'
  35. __version__ = '2.7.0'
  36. __build__ = 0x020700
  37. __author__ = 'Kenneth Reitz'
  38. __license__ = 'Apache 2.0'
  39. __copyright__ = 'Copyright 2015 Kenneth Reitz'
  40. # Attempt to enable urllib3's SNI support, if possible
  41. try:
  42. from .packages.urllib3.contrib import pyopenssl
  43. pyopenssl.inject_into_urllib3()
  44. except ImportError:
  45. pass
  46. from . import utils
  47. from .models import Request, Response, PreparedRequest
  48. from .api import request, get, head, post, patch, put, delete, options
  49. from .sessions import session, Session
  50. from .status_codes import codes
  51. from .exceptions import (
  52. RequestException, Timeout, URLRequired,
  53. TooManyRedirects, HTTPError, ConnectionError
  54. )
  55. # Set default logging handler to avoid "No handler found" warnings.
  56. import logging
  57. try: # Python 2.7+
  58. from logging import NullHandler
  59. except ImportError:
  60. class NullHandler(logging.Handler):
  61. def emit(self, record):
  62. pass
  63. logging.getLogger(__name__).addHandler(NullHandler())