mirror of
https://github.com/fergalmoran/bitchmin.git
synced 2025-12-22 09:27:53 +00:00
13 lines
320 B
Python
13 lines
320 B
Python
from ipaddress import IPv4Address
|
|
|
|
from flask import json
|
|
|
|
|
|
class IPAddressFieldEncoder(json.JSONEncoder):
|
|
" Add support for serializing IPAddress fields"
|
|
|
|
def default(self, value):
|
|
if isinstance(value, IPv4Address):
|
|
return value.exploded
|
|
return json.JSONEncoder.default(self, value)
|