diff --git a/app/__init__.py b/app/__init__.py index 611ce465509dfdab3133a48b79f194b065fb37b0..4c438d634be72c31d4d2f8c9de091de896cc72ad 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,6 +1,5 @@ import os from flask import Flask, render_template -from app.labels_system.label_system import sort class CustomFlask(Flask): jinja_options = Flask.jinja_options.copy() @@ -18,11 +17,14 @@ def create_app(): app.config.from_object(os.environ['LABELSTOWER_ENV']) + + from app.labels_system import bp + app.register_blueprint(bp, url_prefix='/sort') + @app.route('/') @app.route('/browse') def home(): return render_template('browse.html', txt=text_component) - app.register_blueprint(sort, url_prefix='/sort') return app diff --git a/app/labels_system/__init__.py b/app/labels_system/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..5c1516ef35be33d5be7ce8c9a60bdf0cea0a5eea --- /dev/null +++ b/app/labels_system/__init__.py @@ -0,0 +1,6 @@ +from flask import Blueprint + +bp = Blueprint('sort', __name__) + +from app.labels_system import routes + diff --git a/app/labels_system/label_system.py b/app/labels_system/routes.py similarity index 82% rename from app/labels_system/label_system.py rename to app/labels_system/routes.py index 5af4533b12af21b5de9f95e915485bf82f434c4b..f463b735fbb790e8e9ce7a4cf115bfb7f9c92d39 100644 --- a/app/labels_system/label_system.py +++ b/app/labels_system/routes.py @@ -1,15 +1,14 @@ from typing import Dict, List import json -from flask import Blueprint from app.labels_system.getter import get_selected_elements, get_discriminating_labels, get_high_discriminating_labels +from app.labels_system import bp -sort = Blueprint('sort', __name__) #URLs call to update labels and elements along researchs -@sort.route('/search/<int:number_of_mandatory_labels>', defaults={'optional1':'', 'optional2':''}) -@sort.route('/search/<int:number_of_mandatory_labels>/<string:optional1>', defaults={'optional2':''}) -@sort.route('/search/<int:number_of_mandatory_labels>/<string:optional1>/<string:optional2>') +@bp.route('/search/<int:number_of_mandatory_labels>', defaults={'optional1':'', 'optional2':''}) +@bp.route('/search/<int:number_of_mandatory_labels>/<string:optional1>', defaults={'optional2':''}) +@bp.route('/search/<int:number_of_mandatory_labels>/<string:optional1>/<string:optional2>') def search(number_of_mandatory_labels: int, optional1: str, optional2: str) -> List[List[Dict[int, str]]] : ''' Return updated lists of selected elements and high discriminating labels useful to continu research