Faild to make query of user and display the content of the database column

code of app.py = from flask import Flask, render_template, request, jsonify import requests import mysql.connector

app = Flask(name)

Define your MySQL database connection details

MYSQL_HOST = “localhost” MYSQL_USER = “root” MYSQL_PASSWORD = “” MYSQL_DATABASE = “backup”

Define Rasa API URL

RASA_API_URL = ‘http://localhost:5005/webhooks/rest/webhook

def connect_to_database(): try: connection = mysql.connector.connect( host=MYSQL_HOST, user=MYSQL_USER, password=MYSQL_PASSWORD, database=MYSQL_DATABASE ) return connection except mysql.connector.Error as e: print(“Error connecting to MySQL database:”, e) return None

def fetch_email_for_nom(nom): connection = connect_to_database() if connection: cursor = connection.cursor() cursor.execute(“SELECT Email FROM atsufas1 WHERE nom = %s”, (nom,)) row = cursor.fetchone() cursor.close() connection.close() if row: return row[0] # Return the email value else: return “No email found for the given nom.” else: return “Failed to connect to the database.”

@app.route(‘/’) def index(): return render_template(‘index.html’)

@app.route(‘/webhook’, methods=[‘POST’]) def webhook(): user_message = request.json[‘message’] print(“User Message:”, user_message)

# Check if user message is requesting email for nom
if "donner moi l'email de" in user_message.lower():
    # Extract nom from user message
    nom = user_message.split("de ")[1]

    # Fetch email for the given nom value
    email = fetch_email_for_nom(nom)
    bot_response = f"The email corresponding to '{nom}' is: {email}"
else:
    # Send user message to Rasa and get bot's response
    rasa_response = requests.post(RASA_API_URL, json={'message': user_message})
    rasa_response_json = rasa_response.json()
    print("Rasa Response:", rasa_response_json)
    bot_response = rasa_response_json[0]['text'] if rasa_response_json else 'Sorry, I didn\'t understand that.'

return jsonify({'response': bot_response})

if name == ‘main’: app.run(debug=True, port=3000) the error that i face it C:\Users\hi\PycharmProjects\RasaCourse.venv\lib\site-packages\sanic_cors\extension.py:39: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. SANIC_VERSION = LooseVersion(sanic_version) YamlSyntaxException: Failed to read YAML. while scanning a simple key in “”, line 15, column 1: s ^ (line: 15) could not find expected ‘:’ in “”, line 16, column 1: # Tracker store which is used to … ^ (line: 16)

You can use https://yamlchecker.com/ to validate the YAML syntax of your file.