(query_params, param_name, param_type=str, default_value=None)
| 98 | return parsed.netloc.replace('www.', '') |
| 99 | |
| 100 | def get_param(query_params, param_name, param_type=str, default_value=None): |
| 101 | value = query_params.get(param_name, default_value) |
| 102 | if (value is not None): |
| 103 | if param_type is str: |
| 104 | if isinstance(value, list): |
| 105 | return value[0] if value else "" |
| 106 | return value |
| 107 | elif param_type is int: |
| 108 | return int(value) |
| 109 | elif param_type is float: |
| 110 | return float(value) |
| 111 | elif param_type is bool: |
| 112 | if isinstance(value, list): |
| 113 | return value[0].lower() == "true" |
| 114 | return value.lower() == "true" |
| 115 | elif param_type is list: |
| 116 | if isinstance(value, list): |
| 117 | return value |
| 118 | return [item.strip() for item in value.strip('[]').split(',') if item.strip()] |
| 119 | else: |
| 120 | raise ValueError(f"Unsupported parameter type: {param_type}") |
| 121 | return default_value |
| 122 | |
| 123 | def log(message): |
| 124 | print(message) |
no test coverage detected