def get(self): try: args = request.args if 'id' in args: query= """ SELECT * FROM MATCHTYPE WHERE ID = %s """ params = (args['id'],) series = readSQL(query, params) elif 'offset' in args and 'limit' in args: offset = int(request.args['offset']) limit = int(request.args['limit']) query= """ SELECT * FROM MATCHTYPE LIMIT %s OFFSET %s """ params = (limit, offset) series = readManySQL(query, params) else: return {'sucess' : False, 'message': 'missing parameters' }, 400 if series: data = json.dumps({'success' : True, 'data': series}, default=default) return json.loads(data), 200 else: return {'sucess' : False, 'message': 'no records found' }, 404 except Exception as e: app.log.exception(e) return {'success': False, 'message': "SERVER/DB error" }, 500
def get(self): try: args = request.args row_match = '' if 'status' in args and args['status'] == 'LIVE': query_match = """ select match.id, match.name, date, teama.name as teama, teamb.name as teamb, teama.logo as teama_logo, teamb.logo as teamb_logo, matchtype.name, match."date", match.venue from "match" join team as teama on teama.id = match.team_a join team as teamb on teamb.id = match.team_b join matchtype on matchtype.id = match.matchtype_id where match.status = %s """ params = (args['status'], ) row_match = readManySQL(query_match, params) elif 'status' in args and args['status'] == 'UPCOMING': query_match = """ select match.id, match.name, date, teama.name as teama, teamb.name as teamb, teama.logo as teama_logo, teamb.logo as teamb_logo, matchtype.name, match."date", match.venue from "match" join team as teama on teama.id = match.team_a join team as teamb on teamb.id = match.team_b join matchtype on matchtype.id = match.matchtype_id where match.status = %s """ params = (args['status'], ) row_match = readManySQL(query_match, params) elif 'status' in args and args['status'] == 'PAST': query_match = """ select match.id, match.name, date, teama.name as teama, teamb.name as teamb, teama.logo as teama_logo, teamb.logo as teamb_logo, matchtype.name, match."date", match.venue from "match" join team as teama on teama.id = match.team_a join team as teamb on teamb.id = match.team_b join matchtype on matchtype.id = match.matchtype_id where match.status = %s """ params = (args['status'], ) row_match = readManySQL(query_match, params) if row_match and len(row_match) > 0: data = json.dumps({ 'success': True, 'data': row_match }, default=default) return json.loads(data), 200 else: return {'success': False, 'error': 'Data not found'}, 200 except Exception as e: app.log.exception(e) return {'success': False, 'message': "SERVER/DB error"}, 500
def FullScoreCardXML(match_id): get_curr_inng = app.redis.get("match:" + str(match_id) + ":innings") get_inng = json.loads(get_curr_inng) offset = 0 limit = 20 list_key = "list:" + str(match_id) + ":" + str(get_inng) list_commentry = app.redis.lrange(list_key, offset, int(offset) + int(limit) - 1) pipe = app.redis.pipeline() for key in list_commentry: key_split = key.split(':') if (key_split[3] == 'manual'): key_name = key_split[0] + ":" + key_split[1] + ":" + key_split[ 2] + ":" + key_split[3] pipe.hget(key_name, key_split[4]) else: key_name = key_split[0] + ":" + key_split[1] + ":" + key_split[2] field_key = key_split[3] pipe.hget(key_name, field_key) commentry_redis_data = pipe.execute() commentry_data = [] for commentry in commentry_redis_data: obj = {"comment": ''} commentry = json.loads(commentry) if 'datetime' in commentry: obj["comment"] = "<span>" + commentry["datetime"] + "</span>" if 'recent' in commentry: score = commentry["recent"].split(' ') score = score[len(score) - 1] if ("W" in score and "Wd" not in score) or "+W" in score: score = "W" if "+NB" in score: score = "NB" obj["comment"] = obj["comment"] + "<span>" + score + "</span>" if 'over' in commentry: obj["comment"] = obj["comment"] + "<span>" + str( commentry["over"]) + "</span>" obj["comment"] = obj["comment"] + commentry["comment"].replace( 'id="text"', '').replace('<p id="embed">', '<span>').replace( '<p id="embed">', '<span>').replace( '</p><p></p>', '</span>').replace('id="img"', '') obj["comment"] = Markup(obj["comment"]) commentry_data.append(obj) query_match = """ SELECT * FROM MATCH WHERE ID = %s """ params = (match_id, ) match = readManySQL(query_match, params) template = render_template('fullscorecard.xml', match=match[0], commentry_data=commentry_data) response = make_response(template) response.headers['Content-Type'] = 'application/xml' return response
def get(self): try: args = request.args if 'match_id' in args: query_match= """ SELECT SCORE_ID FROM MATCH WHERE ID = %s """ params = (args['match_id'],) row_score = readSQL(query_match, params) if row_score: query_score= """ SELECT SCORECARD_ID FROM SCORE WHERE ID = %s """ params = (row_score['score_id'],) row_scorecard_id = readSQL(query_score, params) if row_scorecard_id: over = '' query_playercard= """ select id, ball_id, team_a_over, team_b_over, innings from playerscorecard where s_id = %s order by innings, team_a_over, team_b_over """ params = (row_scorecard_id['scorecard_id'],) row_match = readManySQL(query_playercard, params) innings_1_list = [] innings_2_list = [] for over in row_match: if over['innings'] == 1: inning_1 = {} inning_1['id'] = over['id'] inning_1['innings'] = over['innings'] inning_1['over'] = over['team_a_over'] inning_1['ball_id'] = over['ball_id'] innings_1_list.append(inning_1) for over in row_match: if over['innings'] == 2: inning_2 = {} inning_2['id'] = over['id'] inning_2['innings'] = over['innings'] inning_2['over'] = over['team_b_over'] inning_2['ball_id'] = over['ball_id'] innings_2_list.append(inning_2) get_curr_inng = app.redis.get("match:"+str(args['match_id'])+":innings") curr_livecard = {} if get_curr_inng: get_inng = json.loads(get_curr_inng) curr_key = "livescorecard:"+str(args['match_id'])+":current:"+str(get_inng) curr_livecard = json.loads(app.redis.get(curr_key)) curr_livecard['innings'] = get_inng data = json.dumps({'success' : True, 'innings_1': innings_1_list, 'innings_2': innings_2_list, 'status': curr_livecard}, default=default) return json.loads(data), 200 except Exception as e: app.log.exception(e) return {'success': False, 'message': "SERVER/DB error" }, 500
def get(self): try: args = request.args if 'id' in args: query = """ SELECT * FROM PLAYER WHERE ID = %s """ params = (args['id'], ) players = readSQL(query, params) elif 'teamid' in args: query = """ SELECT p1.*, t1.NAME as "team_name" FROM PLAYER p1 left join TEAM t1 on p1.team_id=t1.id WHERE p1.TEAM_ID =%s """ params = (args['teamid'], ) players = readManySQL(query, params) elif 'offset' in args and 'limit' in args: offset = int(request.args['offset']) limit = int(request.args['limit']) query = """ SELECT * FROM PLAYER LIMIT %s OFFSET %s """ params = (limit, offset) players = readManySQL(query, params) else: return {'sucess': False, 'message': 'missing parameters'}, 400 if players: data = json.dumps({ 'success': True, 'data': players }, default=default) return json.loads(data), 200 else: return {'sucess': False, 'message': 'no records found'}, 404 except Exception as e: app.log.exception(e) return {'success': False, 'message': "SERVER/DB error"}, 500
def LiveCommentaryXML(): team = { "Australia": 1, "England": 2, "India": 3, "New Zealand": 4, "Pakistan": 5, "South Africa": 6, "Sri Lanka": 7, "West Indies": 8, "Zimbabwe": 9, "Bangladesh": 10, "Netherlands": 14, "Scotland": 15, "Ireland": 24, "Oman": 93, "Afganistan": 95, "Papua New Guinea": 267 } today = date.today() today = today.strftime("%Y-%m-%d") query_match = """ select match.id, match.name, date,teama.id as teamaID, teama.name as teama, teamb.id as teambID,teamb.name as teamb, teamb.logo as teamb_logo,match.date, match.venue from "match" join team as teama on teama.id = match.team_a join team as teamb on teamb.id = match.team_b join matchtype on matchtype.id = match.matchtype_id where match.status = %s """ params = ("UPCOMING", ) matchs = readManySQL(query_match, params) obj = {} matchData = [] for match in matchs: obj = match obj["teamaid"] = team[match["teama"]] obj["teambid"] = team[match["teamb"]] date_time_obj = match["date"] obj["game_date"] = date_time_obj.date().strftime("%Y%m%d") obj["game_date_string"] = date_time_obj.date().strftime('%dth %b %Y') obj["game_date_time"] = date_time_obj obj["time"] = date_time_obj.time() matchData.append(obj) template = render_template('LiveCommentary.xml', today=today, matchData=matchData) response = make_response(template) response.headers['Content-Type'] = 'application/xml' return response
def get(self): try: args = request.args if 'id' in args: query = """ SELECT * FROM TEAM WHERE ID = %s """ params = (args['id'], ) teams = readSQL(query, params) else: query = """ SELECT * FROM TEAM """ teams = readManySQL(query, None) if teams: return {'success': True, 'data': teams}, 200 else: return {'sucess': False, 'message': 'no records found'}, 404 except Exception as e: app.log.exception(e) return {'success': False, 'message': "SERVER/DB error"}, 500
def get(self): try: args = request.args if 'id' in args: query_points = """ SELECT POINTS.G_NAME, POINTS.PLAYED, POINTS.WON, POINTS.LOST, POINTS.NR, POINTS.NRR, TEAM.NAME FROM MATCHTYPE JOIN POINTS ON MATCHTYPE.G_ID = POINTS.G_ID JOIN TEAM ON POINTS.TEAM_ID = TEAM.ID WHERE MATCHTYPE.ID = %s """ params = (args['id'],) points = readManySQL(query_points, params) if points: data = json.dumps({'success' : True, 'data': points}, default=default) return json.loads(data), 200 else: return {'success': False, 'message': 'No points found' }, 404 else: return {'success': False, 'message': 'missing parameters' }, 400 except Exception as e: app.log.exception(e) return {'success': False, 'message': "SERVER/DB error" }, 500
def get(self): try: all_data = {} # team list query_teams = """ SELECT ID, NAME, STATUS, SHORTNAME FROM TEAM """ teams = readManySQL(query_teams, None) # all_data.append({'teams' : teams}) team_enum = {} for item in teams: team_enum[item['id']] = item['name'] team_enum_short = {} for item in teams: team_enum_short[item['id']] = item['shortname'] # all_data.append({'team_enum': team_enum}) # country list query_country = """ SELECT ID, NAME, STATUS FROM COUNTRY """ countries = readManySQL(query_country, None) country_enum = {} for item in countries: country_enum[item['id']] = item['name'] # match type list query_match_type = """ SELECT ID, TYPE, NAME, VENUE FROM MATCHTYPE """ match_type = readManySQL(query_match_type, None) match_type_enum = {} series_match_list = [] tournament_match_list = [] series_match = {} tournament_match = {} for item in match_type: match_type_enum[item['id']] = item['name'] if item['type'] == "SERIES": series_match = {"id": item['id'], "name": item['name']} series_match_list.append(series_match) series_match = {} elif item['type'] == "TOURNAMENT": tournament_match = {"id": item['id'], "name": item['name']} tournament_match_list.append(tournament_match) tournament_match = {} #ball type list query_balltype = """ SELECT ID, NAME, DISPLAY_NAME, STATUS FROM BALLTYPE """ ball_types = readManySQL(query_balltype, None) balltype_enum = {} for item in ball_types: balltype_enum[item['id']] = item['display_name'] #ball type cat list query_cattype = """ SELECT BALL_CAT FROM BALLTYPE GROUP BY BALL_CAT """ ball_type = readManySQL(query_cattype, None) balltype_spin = [] balltype_fast = [] balltype_common = [] for item in ball_type: if (item['ball_cat'] == 'spin'): query_balltype = """ SELECT * FROM BALLTYPE WHERE BALL_CAT = %s """ params = (item['ball_cat'], ) ball_type = readManySQL(query_balltype, params) balltype_spin = ball_type elif (item['ball_cat'] == 'fast'): query_balltype = """ SELECT * FROM BALLTYPE WHERE BALL_CAT = %s """ params = (item['ball_cat'], ) ball_type = readManySQL(query_balltype, params) balltype_fast = ball_type elif (item['ball_cat'] == 'common'): query_balltype = """ SELECT * FROM BALLTYPE WHERE BALL_CAT = %s """ params = (item['ball_cat'], ) ball_type = readManySQL(query_balltype, params) balltype_common = ball_type #short type list query_shottype = """ SELECT ID, NAME, STATUS, DISPLAY_NAME FROM SHOTTYPE """ shot_type = readManySQL(query_shottype, None) shotype_enum = {} for item in shot_type: shotype_enum[item['id']] = item['display_name'] #out type list query_outtype = """ SELECT ID, NAME, STATUS FROM OUT """ out_type = readManySQL(query_outtype, None) #format type list query_format = """ SELECT ID, NAME, STATUS, OVERS, INNINGS FROM FORMAT """ format_type = readManySQL(query_format, None) format_type_enum = {} for item in format_type: format_type_enum[item['id']] = item['name'] #match status query_statustype = """ SELECT ID, NAME, LOCK FROM STATUS """ status_type = readManySQL(query_statustype, None) statustype_enum = {} for item in status_type: statustype_enum[item['id']] = item['name'] #field position query_fieldpos = """ SELECT ID, NAME, STATUS FROM FIELDPOSITION """ field_pos = readManySQL(query_fieldpos, None) fieldpos_enum = {} for item in field_pos: fieldpos_enum[item['id']] = item['name'] all_data = { 'teams': teams, 'team_enum': team_enum, 'team_enum_short': team_enum_short, 'countries': countries, 'country_enum': country_enum, 'balltype': ball_types, 'balltype_enum': balltype_enum, 'balltype_spin': balltype_spin, 'balltype_fast': balltype_fast, 'balltype_common': balltype_common, 'shot_type': shot_type, 'shottype_enum': shotype_enum, 'out_type': out_type, 'format_type': format_type, 'format_type_enum': format_type_enum, 'match_type': match_type, 'match_type_enum': match_type_enum, 'series_match_list': series_match_list, 'tournament_match_list': tournament_match_list, 'match_status': status_type, 'match_status_enum': statustype_enum, 'field_position_enum': fieldpos_enum, 'field_position': field_pos } return {'success': True, 'data': all_data}, 200 except Exception as e: app.log.exception(e) return {'success': False, 'message': "SERVER/DB error"}, 500
def get(self): try: args = request.args if 'type' in args and args['type'] == 'auto' and 'offset' in args and 'limit' in args and 'id' in args: list_key = "list:"+str(args['id'])+":"+str(args['innings']) list_commentry = app.redis.lrange(list_key, args['offset'], int(args['offset'])+int(args['limit']) - 1) pipe = app.redis.pipeline() for key in list_commentry: key_split = key.split(':') if(key_split[3] == 'manual'): key_name = key_split[0]+":"+key_split[1]+":"+key_split[2]+":"+key_split[3] pipe.hget(key_name, key_split[4]) else: key_name = key_split[0]+":"+key_split[1]+":"+key_split[2] field_key = key_split[3] pipe.hget(key_name, field_key) responses = [json.loads(commentry_data) for commentry_data in pipe.execute()] tot_commentry = app.redis.llen(list_key) offset = int(args['limit']) + int(args['offset']) total = tot_commentry - offset if total > 0: return {'success': True, 'data': responses, 'offset': offset} else: return {'success': True, 'data': responses} elif 'type' in args and args['type'] == 'manual': query_comm= """ SELECT ID, COMMENT, OVER, INNINGS FROM COMM WHERE MATCH_ID = %s AND INNINGS = %s ORDER BY ID DESC LIMIT 6 """ params = (args['id'], args['innings']) row_comm = readManySQL(query_comm, params) if row_comm: data = json.dumps({'success' : True, 'data': row_comm}, default=default) return json.loads(data), 200 elif 'type' in args and args['type'] == 'updated': query_comm= """ select playerscorecard.team_a_over, playerscorecard.team_b_over, comm."comment" as manual, playerscorecard."comment" as auto from "match" join score on "match".score_id = score.id join playerscorecard on playerscorecard.s_id = score.scorecard_id join comm on match.id = comm.match_id and playerscorecard.innings = comm.innings and comm.over = playerscorecard.team_a_over where match.id = %s and comm.innings = %s order by comm.id desc limit 6 """ params = (args['id'], args['innings']) row_comm = readManySQL(query_comm, params) if row_comm: row_all = {} row_data_all = [] temp = [] for data in row_comm: row_all = {} if int(args['innings']) == 1: over = 'team_a_over' else: over = 'team_b_over' row_all['over'] = '' row_all['comment'] = '' if data[over] in temp: for val in row_data_all: if val['over'] == data[over]: val['comment'] = val['comment'] +' | '+data['manual'] else: row_all['over'] = data[over] row_all['comment'] = data['auto'] +' | '+data['manual'] row_data_all.append(row_all) temp.append(data[over]) data = json.dumps({'success' : True, 'data': row_data_all}, default=default) return json.loads(data), 200 except Exception as e: app.log.exception(e) return {'success': False, 'message': "SERVER/DB error" }, 500
def get(self): try: args = request.args if args: if 'status' in args and args['status'] == 'ALL': query_match = """ SELECT * FROM MATCH ORDER BY ID ASC """ params = (None, ) elif 'status' in args: query_match = """ SELECT * FROM MATCH WHERE STATUS = %s """ params = (args['status'], ) elif 'id' in args: query_match = """ SELECT * FROM MATCH WHERE ID = %s """ params = (args['id'], ) row_match = readManySQL(query_match, params) if 'status' in args: data = json.dumps({ 'success': True, 'data': row_match }, default=default) return json.loads(data), 200 elif 'id' in args and row_match: query_squad = """ SELECT MATCHTYPE.TYPE, MATCHTYPE.NAME AS MATCHTYPE_NAME, FORMAT.NAME AS FORMAT_NAME, FORMAT.OVERS AS FORMAT_OVERS, FORMAT.INNINGS AS FORMAT_INNINGS, TEAMSQUAD.PLAYER_ID AS ID, PLAYER.NAME, PLAYER.FIRST_NAME, PLAYER.LAST_NAME, PLAYER.BOWLING_CAT, PLAYER.BATTING_STYLE, TEAMSQUAD.TEAM_ID AS TEAM, TEAMSQUAD.T_ID_1, TEAMSQUAD.T_ID_2, TEAMSQUAD.SELECTED, TEAMSQUAD.position, TEAMSQUAD.PLAYER_IN FROM MATCH JOIN SQUAD ON MATCH.SQUAD_ID = SQUAD.ID JOIN TEAMSQUAD ON SQUAD.TEAM_SQUAD_1 = TEAMSQUAD.T_ID_1 OR SQUAD.TEAM_SQUAD_2 = TEAMSQUAD.T_ID_2 JOIN PLAYER ON TEAMSQUAD.PLAYER_ID = PLAYER.ID JOIN FORMAT ON FORMAT.ID = MATCH.FORMAT_ID JOIN MATCHTYPE ON MATCHTYPE.ID = MATCH.MATCHTYPE_ID WHERE MATCH.ID = %s ORDER BY TEAMSQUAD.POSITION asc """ params = (args['id'], ) row_squads = readManySQL(query_squad, params) match_type = row_squads[0]['type'] format_name = row_squads[0]['format_name'] format_overs = row_squads[0]['format_overs'] format_innings = row_squads[0]['format_innings'] matchtype_name = row_squads[0]['matchtype_name'] match = row_match[0] team_squad_1 = [] team_squad_2 = [] for team in row_squads: if team['t_id_1']: team_squad_1.append({ 'id': team['id'], 'name': team['name'], 'first_name': team['first_name'], 'last_name': team['last_name'], 'bowling_cat': team['bowling_cat'], 'team': team['team'], 'selected': team['selected'], 'position': team['position'], 'batting_style': team['batting_style'], 'player_in': team['player_in'] }) for team in row_squads: if team['t_id_2']: team_squad_2.append({ 'id': team['id'], 'name': team['name'], 'first_name': team['first_name'], 'last_name': team['last_name'], 'bowling_cat': team['bowling_cat'], 'team': team['team'], 'selected': team['selected'], 'position': team['position'], 'batting_style': team['batting_style'], 'player_in': team['player_in'] }) query_result = """ SELECT * FROM RESULT WHERE ID = %s; """ params = (match['result_id'], ) row_result = readSQL(query_result, params) obj = { 'id': match['id'], 'name': match['name'], 'date': match['date'], 'local': match['local'], 'venue': match['venue'], 'toss': match['toss'], 'team_a': match['team_a'], 'team_b': match['team_b'], 'status': match['status'], 'team_squad_1': team_squad_1, 'team_squad_2': team_squad_2, 'format_id': match['format_id'], 'matchtype_id': match['matchtype_id'], 'result': row_result, 'score_id': match['score_id'], 'country_id': match['country_id'], 'mom': match['mom'], 'match_type': match_type, 'format_name': format_name, 'format_overs': format_overs, 'format_innings': format_innings, 'matchtype_name': matchtype_name, 'description': match['description'] } data = json.dumps({ 'success': True, 'data': obj }, default=default) return json.loads(data), 200 else: return { 'success': False, 'message': 'match not found' }, 404 except Exception as e: app.log.exception(e) return {'success': False, 'message': "SERVER/DB error"}, 500
def post(self): parser = reqparse.RequestParser(bundle_errors=True) parser.add_argument('id', type=str, required=True, help="match id cannot be missing!", location='json') args = parser.parse_args() try: update_match = """ UPDATE MATCH SET STATUS = 'LIVE' WHERE ID = %s """ params = (args['id'], ) update = writeSQL(update_match, params) if update: squad_key = """ select match.team_a, match.team_b, player.id, player.name, player.first_name, player.last_name, player.batting_style, teamsquad.team_id, teamsquad.selected, teamsquad."position" from match join squad on squad.id = match.squad_id join teamsquad on teamsquad.t_id_1 = squad.team_squad_1 or teamsquad.t_id_2 = squad.team_squad_2 join player on player.id = teamsquad.player_id where match.id= %s and (teamsquad.selected = true or teamsquad.selected = false) GROUP BY teamsquad.team_id, player.id, player.name, teamsquad.team_id, teamsquad."position", match.team_a, match.team_b, teamsquad.selected order by teamsquad."position" asc """ params_key = (args['id'], ) squad_players = readManySQL(squad_key, params_key) if (squad_players): obj = {} # innings 1 formation obj["innings_1"] = {} obj["innings_1"]["batting"] = {} obj["innings_1"]["yetToBat"] = [] for player in squad_players: if (player['team_id'] == player['team_a'] and player['selected']): unq_name = str(player['id']) + "_pname" obj["innings_1"]["batting"][unq_name] = { "id": player['id'], "name": player['name'], "first_name": player['first_name'], "last_name": player['last_name'], "batting_style": player['batting_style'], "status": "", "run": 0, "balls": 0, "four": 0, "six": 0, "strikeRate": 0 } obj["innings_1"]["totalRuns"] = 0 obj["innings_1"]["totalWickets"] = 0 obj["innings_1"]["totalOvers"] = 0 obj["innings_1"]["extras"] = { "byes": 0, "legByes": 0, "wide": 0, "noBall": 0, "pnlt": 0 } obj["innings_1"]["yetToBat"].append(player['name']) obj["innings_1"]["fallOfWickets"] = [] obj["innings_1"]["Bowling"] = {} # innings 2 formation obj["innings_2"] = {} obj["innings_2"]["batting"] = {} obj["innings_2"]["yetToBat"] = [] for player in squad_players: if (player['team_id'] == player['team_b'] and player['selected']): unq_name = str(player['id']) + "_pname" obj["innings_2"]["batting"][unq_name] = { "id": player['id'], "name": player['name'], "first_name": player['first_name'], "last_name": player['last_name'], "batting_style": player['batting_style'], "status": "", "run": 0, "balls": 0, "four": 0, "six": 0, "strikeRate": 0 } obj["innings_2"]["totalRuns"] = 0 obj["innings_2"]["totalWickets"] = 0 obj["innings_2"]["totalOvers"] = 0 obj["innings_2"]["extras"] = { "byes": 0, "legByes": 0, "wide": 0, "noBall": 0, "pnlt": 0 } obj["innings_2"]["yetToBat"].append(player['name']) obj["innings_2"]["fallOfWickets"] = [] obj["innings_2"]["Bowling"] = {} val = json.dumps(obj) key = "fullscorecard:" + str(args['id']) return_key = app.redis.set(key, val) if return_key: return {'success': True}, 200 else: return { 'success': False, 'message': "SERVER/DB error" }, 500 else: return {'success': False, 'message': 'no match found'}, 404 except Exception as e: app.log.exception(e) return {'success': False, 'message': "SERVER/DB error"}, 500