Advertisement
dimkiriakos

bmi_flask

Mar 17th, 2022
863
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1.  
  2. from flask import Flask, request, render_template
  3.  
  4. app = Flask(__name__)
  5.  
  6. @app.route('/', methods =['GET', 'POST'])
  7. def index():
  8.     bmi = 0
  9.     if request.method == 'POST' and request.form.get('weight') and request.form.get('height'):    
  10.         weigtht = float(request.form.get('weight'))
  11.         heigtht = float(request.form.get('height'))
  12.         bmi = weigtht* heigtht
  13.         return render_template('index.html', bmihtml = bmi)
  14.     return render_template('index.html')
  15.        
  16.  
  17. app.debug = True
  18. app.run('0.0.0.0')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement