Advertisement
DragonOsman

quote route, application.py Pset7

Mar 11th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. @app.route("/quote", methods=["GET", "POST"])
  2. @login_required
  3. def quote():
  4.     """Get stock quote."""
  5.    
  6.     # if user reached route via POST
  7.     if request.method == "POST":
  8.        
  9.         # ensure symbol was submitted
  10.         if not request.form.get("symbol"):
  11.             return apology("symbol required")
  12.        
  13.         # look symbol up on Yahoo Finance and check if it was successful
  14.         stock = lookup(request.form.get("symbol"))
  15.         if not stock:
  16.             apology("symbol is invalid/wasn't found or something else went wrong")
  17.        
  18.         return render_template("quoted.html", name="stock")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement