How to use the buku.network_handler function in buku

To help you get started, we’ve selected a few buku examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jarun / Buku / tests / test_buku.py View on Github external
'http://www.vim.org/scripts/script.php?script_id=4641',
            (
                'mlessnau_case - "in-case" selection, deletion and substitution '
                'for underscore, camel, mixed case : vim online',
                None, None, 0, 0
            )
        ],
    ]
)
def test_network_handler_with_url(url, exp_res):
    """test func."""
    import buku
    import urllib3
    buku.urllib3 = urllib3
    buku.myproxy = None
    res = buku.network_handler(url)
    if urlparse(url).netloc == 'www.google.ru':
        temp_res = [res[0].split(" - ")[0], ]
        temp_res.extend(res[1:])
        res = tuple(temp_res)
    assert res == exp_res
github jarun / Buku / bukuserver / server.py View on Github external
def handle_network():
    failed_resp = response.response_template['failure'], status.HTTP_400_BAD_REQUEST
    url = request.data.get('url', None)
    if not url:
        return failed_resp
    try:
        res = network_handler(url)
        keys = ['title', 'description', 'tags', 'recognized mime', 'bad url']
        res_dict = dict(zip(keys, res))
        return jsonify(res_dict)
    except Exception as e:
        current_app.logger.debug(str(e))
    return failed_resp