automated commit by check50 [check50=True]

This commit is contained in:
kukemuna 2024-04-26 08:18:04 +03:00
parent f12011707e
commit b9530e6711
5 changed files with 6 additions and 5 deletions

7
app.py
View File

@ -68,7 +68,7 @@ def buy():
return render_template("buy.html") return render_template("buy.html")
else: else:
symbol = request.form.get("symbol") symbol = request.form.get("symbol")
shares = float(request.form.get("shares")) shares = request.form.get("shares")
if not symbol: if not symbol:
return apology("Not Symbol") return apology("Not Symbol")
@ -78,7 +78,7 @@ def buy():
if stock == None: if stock == None:
return apology("Symbol not found") return apology("Symbol not found")
if not shares == "": if shares:
transaction_value = float(shares) * stock["price"] transaction_value = float(shares) * stock["price"]
user_id = session["user_id"] user_id = session["user_id"]
@ -98,6 +98,8 @@ def buy():
user_id, stock["symbol"], shares, stock["price"], date) user_id, stock["symbol"], shares, stock["price"], date)
flash("Bought!") flash("Bought!")
else:
return apology("Missing shares", 400)
return redirect("/") return redirect("/")
# return apology("TODO") # return apology("TODO")
@ -208,7 +210,6 @@ def register():
username_exists = db.execute("SELECT * FROM users WHERE username = ?", username) username_exists = db.execute("SELECT * FROM users WHERE username = ?", username)
if username_exists: if username_exists:
flash("Username exists already!")
return apology("username already exists!", 400) return apology("username already exists!", 400)
db.execute("INSERT INTO users(username, hash) VALUES(?, ?)", db.execute("INSERT INTO users(username, hash) VALUES(?, ?)",

Binary file not shown.

Binary file not shown.

View File

@ -10,7 +10,7 @@
<input class="form-control mx-auto w-auto" autocomplete="off" autofocus="" name="symbol" placeholder="Symbol" type="text"> <input class="form-control mx-auto w-auto" autocomplete="off" autofocus="" name="symbol" placeholder="Symbol" type="text">
</div> </div>
<div class="mb-3"> <div class="mb-3">
<input class="form-control mx-auto w-auto" autocomplete="off" autofocus min="1" name="shares" placeholder="Shares" type="text"> <input class="form-control mx-auto w-auto" autocomplete="off" autofocus min="1" name="shares" placeholder="Shares" type="number">
</div> </div>
<button class="btn btn-primary" type="submit">Buy</button> <button class="btn btn-primary" type="submit">Buy</button>
</form> </form>