repository to manage all files for 1_2_oder_3 interaction game for Inf2/2 Interaktionen SoSe23 from Engert, Caliskan and Bachiri
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

router.py 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. from flask import Flask, jsonify, Response, request
  2. from game import Game
  3. app = Flask(__name__)
  4. my_game = Game()
  5. @app.route('/question', methods=['GET'])
  6. def get_question():
  7. my_game.get_question()
  8. return jsonify(my_game.question)
  9. @app.route('/teamsize', methods=['POST'])
  10. def teamsize():
  11. team_size = request.json
  12. my_game.set_teamsize(team_size.get('teamsize'))
  13. return Response(status=200)
  14. @app.route('/scoreboard', methods=['GET'])
  15. def scoreboard():
  16. return my_game.scoreboard, Response(status=200)
  17. @app.route('/check', methods=['GET'])
  18. def check():
  19. return my_game.scoreboard
  20. @app.route('/reset', methods=['GET'])
  21. def reset():
  22. my_game.reset_game()
  23. return Response(status=200)
  24. @app.route('/scores', methods=['POST'])
  25. def get_scores():
  26. scores = request.json
  27. my_game.add_score(scores)
  28. return Response(status=200)
  29. def main():
  30. ## ASUS Router
  31. # app.run(host='192.168.50.79', port=5555, debug=True)
  32. ## Postman
  33. app.run(host='127.0.0.1', port=5555, debug=True)
  34. if __name__ == '__main__':
  35. main()