def predict_form(): """функция ввода данных""" dict_data = { "ID": 1, "LicAge": 468, "RecordBeg": "2004-01-01", "RecordEnd": "", "VehAge": "", "Gender": "Male", "MariStat": "Other", "SocioCateg": "CSP50", "VehUsage": "Private", "DrivAge": 67, "HasKmLimit": 0, "BonusMalus": 56, "OutUseNb": 0, "RiskArea": 0 } form = ClientDataForm() if request.method == 'POST': dict_data['ID'] = request.form.get('id') dict_data['DrivAge'] = float(request.form.get('age')) dict_data['LicAge'] = float(request.form.get('lic_age')) dict_data['Gender'] = request.form.get('gender') dict_data['MariStat'] = request.form.get('mari_stat') dict_data['VehAge'] = float(request.form.get('veh_age')) dict_data['BonusMalus'] = float(request.form.get('bonus_malus')) try: response = send_json(dict_data) response = response.text except ConnectionError: response = json.dumps({"error": "ConnectionError"}) return redirect(url_for('predicted', response=response)) return render_template('form.html', form=form)
def predict_form(): form = ClientDataForm() if request.method == 'POST': data['ID'] = request.form.get('id') data['DrivAge'] = float(request.form.get('age')) data['LicAge'] = float(request.form.get('lic_age')) data['Gender'] = request.form.get('gender') data['MariStat'] = request.form.get('mari_stat') data['VehAge'] = float(request.form.get('veh_age')) data['BonusMalus'] = float(request.form.get('bonus_malus')) try: response = send_json(data) response = response.text except ConnectionError: response = json.dumps({"error": "ConnectionError"}) return redirect(url_for('predicted', response=response)) return render_template('form.html', form=form)