Loading server.py +11 −8 Original line number Diff line number Diff line Loading @@ -10,30 +10,33 @@ app = Flask(__name__) # Endpoint to load index.html @app.route('/') @app.route('/index') @app.route('/index', methods=["GET"]) def display_greeting(): #return contents of /web/index.html return send_from_directory('web', 'index.html') # Endpoint to load js files @app.route('/js/main.js') @app.route('/js/main.js', methods=["GET"]) def get_script(): doctype = 'text/js' return send_from_directory('web/js', 'main.js', mimetype=doctype) # Return the prediction label to the frontend @app.route('/predict') @app.route('/predict', methods=["GET"]) def predict(): json = request.get_json() message = json["message"] return message # just for debugging, for now... TODO implement the ml code here for prediction return message # just for debugging, for now... TODO integrate the code with ml.py to get a response # TODO hopefully it's obvious that these functions need to be implemented @app.route('/correctPrediction') @app.route('/correctPrediction', methods=["POST"]) def correctPrediction(): return "Yes, dear" json = request.get_json() message = json["message"] label = json["label"] return label # just for debugging TODO integrate the code with ml.py to get a response @app.route('/getAlgorithms') @app.route('/getAlgorithms', methods=["GET"]) def getTopFiveAlgorithms(): name = ["This (in use)", "Comes", "From", "The", "Server"] f1 = ["5", "4", "3", "2", "1"] Loading @@ -43,7 +46,7 @@ def getTopFiveAlgorithms(): } return val @app.route('/getWords') @app.route('/getWords', methods=["GET"]) def getTopFiveWords(): word = ["Larry", "Schultheis", "Larry", "Schultheis", "Larry"] val = { Loading Loading
server.py +11 −8 Original line number Diff line number Diff line Loading @@ -10,30 +10,33 @@ app = Flask(__name__) # Endpoint to load index.html @app.route('/') @app.route('/index') @app.route('/index', methods=["GET"]) def display_greeting(): #return contents of /web/index.html return send_from_directory('web', 'index.html') # Endpoint to load js files @app.route('/js/main.js') @app.route('/js/main.js', methods=["GET"]) def get_script(): doctype = 'text/js' return send_from_directory('web/js', 'main.js', mimetype=doctype) # Return the prediction label to the frontend @app.route('/predict') @app.route('/predict', methods=["GET"]) def predict(): json = request.get_json() message = json["message"] return message # just for debugging, for now... TODO implement the ml code here for prediction return message # just for debugging, for now... TODO integrate the code with ml.py to get a response # TODO hopefully it's obvious that these functions need to be implemented @app.route('/correctPrediction') @app.route('/correctPrediction', methods=["POST"]) def correctPrediction(): return "Yes, dear" json = request.get_json() message = json["message"] label = json["label"] return label # just for debugging TODO integrate the code with ml.py to get a response @app.route('/getAlgorithms') @app.route('/getAlgorithms', methods=["GET"]) def getTopFiveAlgorithms(): name = ["This (in use)", "Comes", "From", "The", "Server"] f1 = ["5", "4", "3", "2", "1"] Loading @@ -43,7 +46,7 @@ def getTopFiveAlgorithms(): } return val @app.route('/getWords') @app.route('/getWords', methods=["GET"]) def getTopFiveWords(): word = ["Larry", "Schultheis", "Larry", "Schultheis", "Larry"] val = { Loading