diff --git a/src/app/main.py b/src/app/main.py index 6b26e4d..2f726ba 100644 --- a/src/app/main.py +++ b/src/app/main.py @@ -33,11 +33,17 @@ alibaba_embeddings=load_embeddings(alibaba_embeddings_path) @app.route("/", methods=["GET", "POST"]) def index(): if request.method == "POST": - user_input = request.form["description"] - model_type = request.form["model_type"] - performance_choice = request.form["preference_choice"] - similarity_metric = request.form["similarity_metric"] + user_input = request.form.get("description", "").strip() + if not user_input: + return render_template( + "index.html", + error="Please provide a description to get movie recommendations." + ) + model_type = request.form.get("model_type", "") + performance_choice = request.form.get("preference_choice", "") + similarity_metric = request.form.get("similarity_metric", "") + if model_type == "bert": model = bert_model tokenizer = bert_tokenizer diff --git a/src/app/templates/index.html b/src/app/templates/index.html index 5ff440f..24745d7 100644 --- a/src/app/templates/index.html +++ b/src/app/templates/index.html @@ -42,10 +42,16 @@

Filmosfera

+ {% if error %} + + {% endif %} +
- +
@@ -65,10 +71,10 @@
@@ -94,4 +100,4 @@
- \ No newline at end of file +