Source code for bag.web

"""The bag.web module contains code that helps web development generically.

Then there's a :py:mod:`bag.web.pyramid` module that integrates the
generic code into the Pyramid web framework (as can be done with other

import hashlib
from urllib.parse import urlencode

[docs]def gravatar_image( email: str, default: str='mm', size: int=80, cacheable: bool=True, ) -> str: """Return a Gravatar image URL for this ``email``.""" base = "" if cacheable else \ "" return base + \ hashlib.md5(email.encode('utf8').lower()).hexdigest() + \ "?" + urlencode({'d': default, 's': str(size)})