Skip to content

Instantly share code, notes, and snippets.

@Createdd
Created September 26, 2020 14:53
Show Gist options
  • Save Createdd/588bcc886f0d3c57b79410e60f7b0fe2 to your computer and use it in GitHub Desktop.
Save Createdd/588bcc886f0d3c57b79410e60f7b0fe2 to your computer and use it in GitHub Desktop.
@app.route('/predict',methods=['POST'])
def predict():
input_val = [x for x in request.form.values()][0]
rf = load_model(BUCKET_NAME, MODEL_FILE_NAME, MODEL_LOCAL_PATH)
if input_val not in available_countries:
return f'Country {input_val} is not in available list. Try one from the list! Go back in your browser', 400
to_pred = get_prediction_params(input_val, url_to_covid)
prediction = rf.predict(to_pred)[0]
return render_template('home.html',pred=f'New cases will be {prediction}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment