import json with open("static/files/origin-codes.json", "r", encoding="utf-8") as file: origin_codes = json.load(file) def get_origin_id_and_code(origin: str): for x in origin_codes: if x and x.get("name"): if origin == x["name"]: id = x["id"], code = x["code"] return id, code return None, None