-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathod_app.py
52 lines (44 loc) · 1.38 KB
/
od_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from flask import Flask, jsonify
from handler.appl_handler import ApplicationHandler
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
handler = ApplicationHandler()
@app.route('/', methods=['GET', 'POST'])
def index():
try:
return handler.index()
except Exception as e:
return jsonify({'error': str(e)}), 500
@app.route('/api/clubs', methods=['GET'])
def get_clubs():
try:
return handler.get_clubs()
except Exception as e:
return jsonify({'error': str(e)}), 500
@app.route('/api/clubs/add', methods=['POST'])
def add_club():
try:
return handler.add_club()
except Exception as e:
return jsonify({'error': str(e)}), 500
@app.route('/api/clubs/<int:club_id>', methods=['GET'])
def get_club_by_id(club_id):
try:
return handler.get_club_by_id(club_id)
except Exception as e:
return jsonify({'error': str(e)}), 500
@app.route('/api/clubs/update/<int:club_id>', methods=['PUT'])
def update_club(club_id):
try:
return handler.update_club(club_id)
except Exception as e:
return jsonify({'error': str(e)}), 500
@app.route('/api/clubs/delete/<int:club_id>', methods=['DELETE'])
def delete_club(club_id):
try:
return handler.delete_club(club_id)
except Exception as e:
return jsonify({'error': str(e)}), 500
if __name__ == '__main__':
app.run(debug=True)