- from flask import Flask, jsonify, Response, request
- from game import Game
-
- app = Flask(__name__)
-
- my_game = Game()
-
- @app.route('/question', methods=['GET'])
- def get_question():
- my_game.get_question()
- print(my_game.question)
- return jsonify(my_game.question)
-
- @app.route('/teamsize', methods=['POST'])
- def teamsize():
- team_size = request.json
- my_game.set_teamsize(team_size.get('teamsize'))
- print(f'Teamsize: {my_game.teamsize}\n')
- return Response(status=200)
-
- @app.route('/scoreboard', methods=['GET'])
- def scoreboard():
- my_game.set_scoreboard()
- print(my_game.scoreboard)
- return jsonify(my_game.scoreboard)
-
- @app.route('/check', methods=['GET'])
- def check():
- return my_game.scoreboard
-
- @app.route('/reset', methods=['GET'])
- def reset():
- my_game.reset_game()
- return Response(status=200)
-
- @app.route('/scores', methods=['POST'])
- def get_scores():
- scores = request.json
- my_game.add_score(scores)
- return Response(status=200)
-
- @app.route('/winner', methods=['GET'])
- def set_winner():
- my_game.final_result()
- return jsonify(my_game.final_score)
-
- def main():
- ## Router
- # app.run(host='192.168.50.79', port=5555, debug=True)
-
- ## Postman
- app.run(host='127.0.0.1', port=5555, debug=True)
-
-
-
- if __name__ == '__main__':
- main()
-
-
|