Skip to content

Instantly share code, notes, and snippets.

@wasabigeek
Created April 23, 2018 17:48
Show Gist options
  • Save wasabigeek/e57434c11829fa65b9b7d566b127c2cc to your computer and use it in GitHub Desktop.
Save wasabigeek/e57434c11829fa65b9b7d566b127c2cc to your computer and use it in GitHub Desktop.
def validate_symbol_and_lookup(symbol):
if not symbol:
return apology("must provide symbol", 400)
stock = lookup(symbol)
if not stock:
return apology("invalid stock symbol", 400)
return stock
symbol = request.form.get("symbol")
# apology() doesn't get rendered if symbol is invalid
stock = validate_and_lookup(symbol)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment