from flask import( request, jsonify, Blueprint, ) from application.functions.sentiment import sentiment_prediction, count_predictions, clear_data, scrapp_comments sentiment_service = Blueprint("sentiment_service", __name__) @sentiment_service.route("/get_sentiment_data", methods=['POST']) def get_data(): data = request.get_json() data_clear = clear_data(data) #czyszczenie danych wejsciowych predicitons = sentiment_prediction(data_clear) #predykcje count_labels = count_predictions(predicitons) #dane do wykresu for i in range(0, len(predicitons)): predicitons[i]['sentence'] = data['sentences'][i] predicitons[i]['label'] = predicitons[i]['label'][6:] return jsonify({"predictions": predicitons, "count_labels": count_labels}) @sentiment_service.route("/scrapp_comments", methods=['POST']) def scrapp(): try: url = request.get_json() result = scrapp_comments(url['link']) result['status'] = True return result except: return jsonify({'status':False}) @sentiment_service.route("/hello", methods=['POST']) def elo(): return "helo world"