diff --git a/api/app.py b/api/app.py index e63700f0..3a4ad7db 100644 --- a/api/app.py +++ b/api/app.py @@ -1,6 +1,7 @@ from flask import Flask, jsonify, request from flask_cors import CORS from DataProcesser import DataProcesser +from available_classifiers import get_available_classifiers import os import atexit @@ -18,6 +19,10 @@ data_processer = DataProcesser() +def run_flask_app(): + global server_thread + app.run(host='0.0.0.0', port=5000, debug=True, use_reloader=False) + def shutdown_server(): print("Server shutting down...") os.kill(os.getpid(), 9) @@ -38,15 +43,16 @@ def upload_file(): return jsonify({'result': result.to_json()}) +@app.route('/get-classifiers', methods=["GET"]) +def get_classifiers(): + classifiers = get_available_classifiers() + return jsonify(classifiers) + @app.get('/shutdown') def shutdown(): shutdown_server() return 'Server shutting down...' -def run_flask_app(): - global server_thread - app.run(host='0.0.0.0', port=5000, debug=True, use_reloader=False) - if __name__ == '__main__': server_thread = threading.Thread(target=run_flask_app) server_thread.start() diff --git a/api/available_classifiers.py b/api/available_classifiers.py new file mode 100644 index 00000000..b42bcaac --- /dev/null +++ b/api/available_classifiers.py @@ -0,0 +1,6 @@ +def get_available_classifiers(): + return [ + {'id': 0, 'name': 'Naive-Bayes Emotions'}, + {'id': 1, 'name': 'Naive-Bayes News Topics'}, + {'id': 2, 'name': 'Linear Regression Emotions'} + ] \ No newline at end of file