-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup the matches table and api access to it
- Loading branch information
Showing
4 changed files
with
49 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,55 @@ | ||
from flask import Blueprint, Response, jsonify, request | ||
|
||
from api.consts import COMMON_API_PREFIX | ||
from api.model.matches import getAllMatches, getMatch, getMatchesByTeam | ||
from api.model.matches import getAllMatches, getMatch, getMatchesByTeam, insertMatch | ||
|
||
matches_api = Blueprint( | ||
"matches_api", __name__, url_prefix= COMMON_API_PREFIX + "/matches" | ||
) | ||
|
||
@matches_api.route("/", methods=["GET"]) | ||
def get_all(): | ||
def api_get_all(): | ||
try: | ||
responseObject = getAllMatches() | ||
return responseObject | ||
except Exception as e: | ||
print(e) | ||
return Response("smth went wrong", 500) | ||
|
||
@matches_api.route("/" , methods=["POST", "PUT"]) | ||
def api_insertMatch(): | ||
if request.method == "POST": | ||
try: | ||
content = request.json | ||
teamid1 = content["teamid1"] | ||
teamid2 = content["teamid2"] | ||
except Exception as e: | ||
print(e) | ||
return Response("Bad reequest", 400) | ||
|
||
try: | ||
insertMatch(teamid1, teamid2) | ||
return Response("done", 200) | ||
except Exception as e: | ||
print(e) | ||
return Response("something went wrong xxx", 500) | ||
|
||
@matches_api.route("/match/<matchid>") | ||
def api_getByMatchId(matchid): | ||
try: | ||
responseObject = getMatch(matchid) | ||
return responseObject | ||
except Exception as e: | ||
print(e) | ||
return Response("smth went wrong", 500) | ||
|
||
@matches_api.route("/team/<teamid>") | ||
def api_getByTeamId(teamid): | ||
try: | ||
responseObject = getMatchesByTeam(teamid) | ||
return responseObject | ||
except Exception as e: | ||
print(e) | ||
return Response("smth went wrong", 500) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters