etiquette/frontends/etiquette_flask/backend/helpers.py
2020-03-28 17:37:28 -07:00

14 lines
316 B
Python

def dict_to_params(d):
'''
Given a dictionary of URL parameters, return a URL parameter string.
{'a':1, 'b':2} -> '?a=1&b=2'
'''
if not d:
return ''
params = [f'{key}={value}' for (key, value) in d.items()]
params = '&'.join(params)
params = '?' + params
return params