Как решить ошибку "jinja2.exceptions.UndefinedError: 'get_count' is undefined".

Я работаю над небольшим приложением на питоне используя flask app при нажатии на ссылку local host я не получаю ошибку internal server error и ошибку jinja2.exceptions я не знаю где я сделал ошибку нормальный питон мой скрипт работает и дает результат html страница не может прочитать мой вывод id_count как решить это используя python flask вот мой скрипт

import numpy as np
from flask import Flask, render_template, request
app = Flask(__name__)
x = np.array([0, 7, 18, 24, 26, 27, 26, 25, 26, 16, 20, 16, 23, 33, 27, 27,
22, 26, 27, 26, 25, 24, 25, 26, 23, 25, 26, 24, 23, 12, 22, 11, 15, 24, 11,
12, 11, 27, 19, 25, 26, 21, 23, 26, 13, 9, 22, 18, 23, 26, 26, 25, 10, 22,
27, 25, 19, 10, 15, 20, 21, 13, 16, 16, 15, 19, 17, 20, 24, 26, 20, 23, 23,
])
@app.route('/')
def main():
    return render_template('index.html')
@app.route('/send', methods=['POST'])
def get_count(id_count):
    sub_lists = np.split(x, np.where(np.diff(x) <0)[0] + 1)
    id_count=0
    id_list = []
    for unit in sub_lists:
      if min(unit) ==0 and max(unit)>20 and len(set(unit)) > 1:
         id_count += 1
         id_list.append(unit)
      return id_count
      return render_template("index.html",get_count(x))

print("Number of counts: ",get_count(x))
if __name__=="__main__":
    app.run(debug=False, port=1223)
``` this is my app.py file 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
<form action="/data" method = "POST">

<h2> flask app for counting accelerations</h2>
    <p>The acceleration count is "{{get_count(x)}}"</p>

</form>
</head>
</html>
how to correct my html page for getting count value expected out "The acceleration count is 4(some value)"

Я думаю, что вы должны назвать параметр в коде python :

render_template("index.html",count_result=get_count(x))

И используйте его в своем шаблоне, а не пытайтесь использовать функцию python :

{{ count_result }}

Какой предварительный комментарий отправить и удалить возврат id_count из функции get_count

Вернуться на верх