sorry to asking questions like this I am new to flask and html not able to figure out error where I am getting. building small application where it calculates the cycle count of the time series curves when curve profile lower end value <13 and peak end of the curve >20 my script calculates the count how many time the curve goes up above >20 and billow 13 values this is i did for static data if user input the data below 4 and above 15 it has to show the count value so far i used this script for count calculation
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,
25, 19, 15, 16, 27, 26, 27, 28, 24, 23, 24, 27, 28, 30, 31, 30, 9, 0, 11,
16, 25, 25, 22, 25, 25, 11, 15, 24, 24, 24, 17, 0, 23, 21, 0, 24, 26, 24,
26, 26, 26, 24, 25, 24, 24, 22, 22, 22, 23, 24, 26,23])
@app.route('/')
def main():
return render_template('index.html',count_result=get_count(x))
@app.route('/send', methods=['POST'])
def get_count(id_count):
first_input1=request.form["Input1"]
first_input2 = request.form["Input2"]
unit=int(first_input1)
unit=int(first_input2)
sub_lists = np.split(x1, np.where(np.diff(x1) < 0)[0] + 1)
id_count = 0
id_list = []
for unit in sub_lists:
if min(unit) <= 13 and max(unit) > 20 and len(set(unit)) > 1:
id_count += 1
id_list.append(unit)
return render_template(
'index.html',
unit=unit,
count_result=get_count(x1))
return id_count
return render_template("index.html", get_count(x1))
print("Number of counts: ", get_count(x))
if __name__=="__main__":
app.run(debug=False, port=1223)
the values min(unit) and max(unit) in this script are static if user changes the values by inputs the values from UI the count has to get i have so much data like this for counting cycles how to approach this
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calculator</title>
</head>
<body>
<h1> Acceleration Calculator</h1>
<form method="POST">
<input type="text" name="Input1" id="Input1">
<input type="text" name="Input2" id="Input2">
<input type="submit" value="Submit"/>
<br />
<br />
<p>the acceleration count lower end bilow 0 to 13 and upper end limits in between above 18 and bilow 26 is.....{{count_result}} </p>
</form>
</body>
</html>