ahmedraza

quote.py

Feb 19th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. @app.route("/quote", methods=["GET","POST"])
  2. @login_required
  3. def quote():
  4.     #Ensure method of access is get
  5.     if request.method == "GET":
  6.         #take symbol from user
  7.         symbl = request.form.get("symbol")
  8.         if not symbl:
  9.             return apology ("Must enter the symbol")
  10.         #Lookup and save dict in quoted    
  11.         quoted = lookup(symbl)
  12.         #If symbol is invalid return apology
  13.         if not quoted:
  14.             return apology ("Invalid stock")
  15.         #render values to quoted.html    
  16.         else:    
  17.             return render_template ("quoted.html", name = quoted.name,price = quoted.price, symbol = quoted.symbol)
  18.     else:
  19.         return redirect (url_for("quote"))
Add Comment
Please, Sign In to add comment