You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

42 lines
1.2 KiB

#!/usr/bin/env python3
from flask import Flask, render_template, request, url_for
import csv_parser as hcal
app = Flask(__name__)
# easier dev
app.config['TEMPLATES_AUTO_RELOAD']=True
@app.route('/')
def form():
return render_template('form.html')
@app.route('/submit', methods=['POST'])
def submit():
gender = request.form['gender']
if gender == "male":
gender = 'boys'
else:
gender = 'girls'
weight = float(request.form['weight'])
height = float(request.form['height'])
hc = float(request.form['hc'])
age_year = int(request.form['age_year'])
age_month = int(request.form['age_month'])
age = (12*age_year) + age_month
w_normal = hcal.is_weight_age_normal(gender, weight, age)
h_normal = hcal.is_height_age_normal(gender, height, age)
head_normal = hcal.is_head_age_normal(gender, hc, age)
print('W: {0}, H: {1}, HC: {2}, A: {3}'.format(weight, height, hc, age))
return render_template('submit.html',
weight = w_normal,
height = h_normal,
hc = head_normal,
)
if __name__ == "__main__":
app.run(
host='0.0.0.0',
port=8080
)