-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
52 lines (38 loc) · 1.3 KB
/
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
import flask
from flask import Flask, request, jsonify, abort, render_template
from crud.crud_tournament import *
app = Flask(__name__)
app.config["DEBUG"] = True
@app.route('/', methods=['GET'])
def home():
return render_template('home.html')
@app.route('/about/')
def about():
return render_template('about.html')
@app.route('/cards', methods=['GET'])
def read_cards():
return print('')
@app.route('/users', methods=['GET'])
def read_users():
return print('')
@app.route('/tournaments', methods=['POST'])
@app.route('/tournaments/', methods=['POST'])
def post_tournament():
content = request.get_json()
return flask.jsonify(create_tournament(content['title']))
@app.route('/tournaments/', methods=['GET'])
@app.route('/tournaments', methods=['GET'])
def get_tournaments():
tournament_id = request.args.get('tournamentId')
return flask.jsonify(query_tournaments(tournament_id))
@app.route('/tournaments', methods=['DELETE'])
@app.route('/tournaments/', methods=['DELETE'])
def del_tournament():
tournament_id = request.args.get('tournamentId')
title = request.args.get('title')
print(tournament_id)
try:
return flask.jsonify(delete_tournament(tournament_id, title))
except Exception as error:
return jsonify({'error': error})
app.run(debug=True)