Skip to content

Commit

Permalink
available classifier route
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasgabriel18 committed Nov 17, 2023
1 parent a488458 commit 85b2dc3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
14 changes: 10 additions & 4 deletions api/app.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand All @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions api/available_classifiers.py
Original file line number Diff line number Diff line change
@@ -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'}
]

0 comments on commit 85b2dc3

Please sign in to comment.