コード例 #1
0
ファイル: character.py プロジェクト: rafabispo93/marvelApi
def index(char_id, suffix):
    try:
        if char_id:
            res_by_id = DB.get_by_id(int(char_id))
            if suffix in SUFFIXES and res_by_id:
                return res_by_id[suffix], 200
            elif suffix:
                return "Not implemented", 501
            if res_by_id:
                return json.loads(JSONEncoder().encode(res_by_id)), 200
            return "Character not found", 200
        res = DB.get_all()
        if res:
            return JSONEncoder().encode(res), 200
        return "No characters found"
    except Exception as err:
        raise Exception(err)
        return "Internal server error", 500