try out django
[mlpccg-meta.git] / main.py
diff --git a/main.py b/main.py
index 75e5732..c070854 100644 (file)
--- a/main.py
+++ b/main.py
@@ -1,9 +1,32 @@
-from flask import Flask
+from flask import Flask, jsonify, make_response
+from mlpccg.TournamentRecords import TournamentRecords
+from mlpccg.Clustering import Clustering
+
 app = Flask(__name__)
 
-@app.route('/')
-def hello_ponyville():
-    return 'Hello, Ponyville!'
+@app.errorhandler(404)
+def not_found(error):
+    return make_response(jsonify({'error': 'Not found'}), 404)
+
+@app.route('/1.0/records', methods=['GET'])
+def records_list():
+    records = TournamentRecords()
+    return jsonify({'records': records.all()})
+
+
+"""
 
+deck url -> similiar decks with placement
+cluster -> decks in cluster with placement
+-> list clusters, decks with placement
+placement, deck url -> update clusters
+
+
+"""
 if __name__ == '__main__':
-    app.run(host='0.0.0.0', debug=True)
+    app.run(host='0.0.0.0', port=8000, debug=True)
+
+    # clustering = Clustering(tournament_records)
+
+    # for placement_avg, cluster_label in clustering.ranking():
+    #     print '%.1f - %s' % (placement_avg, '; '.join(list(set(map(lambda x: x.name, clustering.clusters[cluster_label])))))