Explicit open / close... (recommended)
>>> with hip.Client() as c:
>>> ...Simple usage...
>>> c = hip.Client()
>>> c.close()Requests...
>>> c = hip.Client()
>>> r = c.get('https://www.example.com/')
>>> r
<Response [200 OK]>>>> c = hip.Client()
>>> u = hip.URL('https://www.example.com/', params={'search': '...'})
>>> r = c.get(u)
>>> r
<Response [200 OK]>>>> f = hip.Form({'email': '...', 'message': '...'})
>>> r = c.post('https://www.example.com/', content=f)
>>> r
<Response [200 OK]>>>> j = hip.JSON({'title': ..., 'rating': ...})
>>> r = c.put('https://www.example.com/', content=j)
>>> r
<Response [200 OK]>>>> j = hip.JSON({'title': ..., 'rating': ...})
>>> r = c.patch('https://www.example.com/', content=j)
>>> r
<Response [200 OK]>>>> c = hip.Client()
>>> r = c.delete('https://www.example.com/')
>>> r
<Response [200 OK]>>>> c = hip.Client()
>>> r = c.head('https://www.example.com/')
>>> r
<Response [200 OK]>Context-managed server...
>>> with hip.Server(app) as server:
... print(server.url)
... server.until_interrupt()The context manager starts the server on entry and shuts it down on exit.
Address...
>>> # Serve locally on a fixed port.
>>> with hip.Server(app, host='127.0.0.1', port=8000) as server:
... print(server.url)
... server.until_interrupt()>>> # Serve on all interfaces on a fixed port.
>>> with hip.Server(app, host='0.0.0.0', port=8000) as server:
... print(server.url)
... server.until_interrupt()>>> r = hip.Request(method, url, headers=..., content=...)Attributes...
>>> r = hip.Request('GET', 'https://www.example.com')
>>> r.method
>>> r.url
>>> r.headers
>>> r.content>>> r = hip.Response(status_code, headers=..., content=...)Attributes...
>>> r = hip.Response(200, content=hip.JSON({'message': 'hello, world'}))
>>> r.status_code
>>> r.headers
>>> r.content>>> m = hip.Method('GET')
>>> m == 'GET'
True
>>> str(m)
'GET'>>> s = hip.StatusCode(200)
>>> s.value, s.reason
(200, 'OK')
>>> s == 200
TrueStatus classes...
>>> s = hip.StatusCode(200)
>>> s.is_1xx_informational()
False
>>> s.is_2xx_success()
True
>>> s.is_3xx_redirect()
False
>>> s.is_4xx_client_error()
False
>>> s.is_5xx_server_error()
False>>> h = hip.Headers({...})
>>> h['Content-Type']
...
>>> h.get('content-type')
...Multi-dict...
>>> h.get_all('set-cookie')
>>> h.multi_items()Updates...
>>> h = h.copy_set(...)
>>> h = h.copy_append('set-cookie', 'session_id=...')
>>> h = h.copy_remove(...)
>>> h = h.copy_update(...)>>> u = hip.URL('...')
>>> u == '...'
TrueQuery parameters...
>>> u = hip.URL('...', params={'search': ...})
>>> u.params
<QueryParams ...>Components...
>>> u.scheme
>>> u.host
>>> u.port
>>> u.path
>>> u.query>>> u.netloc # 'example.com:8080' (HTTP request Host header)
>>> u.target # '/path?query' (HTTP request target)Instantiate from components...
>>> u = hip.URL(scheme='https', host='www.example.com', path='/')Updates...
>>> u = u.copy_with(scheme='https')Joins...
>>> u = hip.URL('https://www.example.com/location')
>>> u = u.join('/redirect')>>> q = hip.QueryParams("...")
>>> q['...']
>>> q.get('...')Multi-dict...
>>> q.get_all()
...
>>> q.multi_items()
...Updates...
>>> q = q.copy_set('search', '...')
>>> q = q.copy_append('color', 'red')
>>> q = q.copy_remove('ordering')
>>> q = q.copy_update({...})Content types for requests...
>>> j = hip.JSON(...)>>> f = hip.Form(...)>>> m = hip.MultiPart(...)Content types for responses...
>>> h = hip.HTML('<html><body>¡Hola, mundo!</body></html>')>>> t = hip.Text('hello, world')>>> j = hip.JSON({'content': ...})>>> f = hip.File('image.png')— 💖 —