automated commit by check50 [check50=True]

This commit is contained in:
kukemuna 2024-04-25 23:53:15 +03:00
parent 6e3bc7d7aa
commit 0e5f4507bd
5 changed files with 9 additions and 3 deletions

10
app.py
View File

@ -68,7 +68,7 @@ def buy():
return render_template("buy.html")
else:
symbol = request.form.get("symbol")
shares = request.form.get("shares")
shares = float(request.form.get("shares"))
if not symbol:
return apology("Not Symbol")
@ -79,7 +79,7 @@ def buy():
return apology("Symbol not found")
if not shares == "":
transaction_value = int(shares) * stock["price"]
transaction_value = float(shares) * stock["price"]
user_id = session["user_id"]
user_cash_db = db.execute("SELECT cash FROM users WHERE id = ?", user_id)
@ -205,6 +205,12 @@ def register():
username = request.form.get("username")
password = request.form.get("password")
username_exists = db.execute("SELECT * FROM users WHERE username = ?", username)
if username_exists:
flash("Username exists already!")
return render_template("register.html")
db.execute("INSERT INTO users(username, hash) VALUES(?, ?)",
username, generate_password_hash(password))
return redirect("/")

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">
</div>
<div class="mb-3">
<input class="form-control mx-auto w-auto" autocomplete="off" autofocus min="1" name="shares" placeholder="Shares" type="number">
<input class="form-control mx-auto w-auto" autocomplete="off" autofocus min="1" name="shares" placeholder="Shares" type="text">
</div>
<button class="btn btn-primary" type="submit">Buy</button>
</form>