try out django
[mlpccg-meta.git] / main.py
1 from flask import Flask, jsonify, make_response
2 from mlpccg.TournamentRecords import TournamentRecords
3 from mlpccg.Clustering import Clustering
4
5 app = Flask(__name__)
6
7 @app.errorhandler(404)
8 def not_found(error):
9 return make_response(jsonify({'error': 'Not found'}), 404)
10
11 @app.route('/1.0/records', methods=['GET'])
12 def records_list():
13 records = TournamentRecords()
14 return jsonify({'records': records.all()})
15
16
17 """
18
19 deck url -> similiar decks with placement
20 cluster -> decks in cluster with placement
21 -> list clusters, decks with placement
22 placement, deck url -> update clusters
23
24
25 """
26 if __name__ == '__main__':
27 app.run(host='0.0.0.0', port=8000, debug=True)
28
29 # clustering = Clustering(tournament_records)
30
31 # for placement_avg, cluster_label in clustering.ranking():
32 # print '%.1f - %s' % (placement_avg, '; '.join(list(set(map(lambda x: x.name, clustering.clusters[cluster_label])))))