mirror of https://github.com/me50/kukemuna.git
automated commit by check50 [check50=True]
This commit is contained in:
parent
6e3bc7d7aa
commit
0e5f4507bd
10
app.py
10
app.py
|
|
@ -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 = request.form.get("shares")
|
shares = float(request.form.get("shares"))
|
||||||
|
|
||||||
if not symbol:
|
if not symbol:
|
||||||
return apology("Not Symbol")
|
return apology("Not Symbol")
|
||||||
|
|
@ -79,7 +79,7 @@ def buy():
|
||||||
return apology("Symbol not found")
|
return apology("Symbol not found")
|
||||||
|
|
||||||
if not shares == "":
|
if not shares == "":
|
||||||
transaction_value = int(shares) * stock["price"]
|
transaction_value = float(shares) * stock["price"]
|
||||||
|
|
||||||
user_id = session["user_id"]
|
user_id = session["user_id"]
|
||||||
user_cash_db = db.execute("SELECT cash FROM users WHERE id = ?", 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")
|
username = request.form.get("username")
|
||||||
password = request.form.get("password")
|
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(?, ?)",
|
db.execute("INSERT INTO users(username, hash) VALUES(?, ?)",
|
||||||
username, generate_password_hash(password))
|
username, generate_password_hash(password))
|
||||||
return redirect("/")
|
return redirect("/")
|
||||||
|
|
|
||||||
BIN
finance.db
BIN
finance.db
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -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="number">
|
<input class="form-control mx-auto w-auto" autocomplete="off" autofocus min="1" name="shares" placeholder="Shares" type="text">
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-primary" type="submit">Buy</button>
|
<button class="btn btn-primary" type="submit">Buy</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue