Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask, render_template, request
- app = Flask(__name__)
- #serve up the main page (index)
- @app.route("/")
- def index():
- return render_template("index.html")
- #process form submit data and give results HTML page
- @app.route("/convert")
- def convert():
- #get info from the submitted form
- fname = request.args['firstname']
- lname = request.args['lastname']
- dollars = request.args['dollars']
- cents = request.args['cents']
- history = request.args['history']
- math = request.args['math']
- english = request.args['english']
- science = request.args['science']
- lang = request.args['lang']
- #do the conversion calc (100 -> 4.0)
- avg = (int(history) + int(math) + int(english) + int(science) + int(lang)) / 5
- if avg > 97:
- gpa = 4.3
- elif avg > 93:
- gpa = 4.0
- elif avg > 90:
- gpa = 3.7
- elif avg > 87:
- gpa = 3.3
- else:
- gpa = 2.0
- #build the results HTML page
- return "Your GPA is " + str(gpa)
Add Comment
Please, Sign In to add comment