I can't pass inputted in HTML form value to python via request.form.get('name'). I watсhed youtube and found original function request.form['name'] that doesn't work as well. Even tried to pass values to js first and then pass it to python, didn't help.
HTML page from which I want to get input:
<script src="https://cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-
validator/0.11.9/validator.min.js"></script>
<div id="reg">
<div class="container w">
<div class="row centered">
<br>
<div class="col-lg-5 col-lg-offset-3">
<form data-toggle="validator" role="form">
<div class="form-group">
<label for="inputName" class="control-label">Name</label>
<input name="userus" autocomplete="off" autofocus type="text" class="form-
control" id="inputName" placeholder="Your name" required>
<div class="help-block">Input your name</div>
</div>
<div class="form-group">
<label for="inputPassword" class="control-label">Password</label>
<div class="form-inline row">
<div class="form-group col-sm-6">
<input name="password" autocomplete="off" autofocus type="password"
data-minlength="3" class="form-control" id="inputPassword"
placeholder="Password" required>
<div class="help-block">Minimum of 3 characters</div>
</div>
<div class="form-group col-sm-6">
<input name="confpassword" autocomplete="off" autofocus type="password"
class="form-control" id="inputPasswordConfirm" data-
match="#inputPassword" data-match-error="Whoops, these don't match"
placeholder="Confirm" required>
<div class="help-block with-errors"></div>
</div>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn" id="bt1">Submit</button>
</div>
</div> </div> </div>
<div>
{{nom1}}, {{nom2}}, {{nom3}}
</div>
</form>
Original code (python) of the page where I want to recive values:
@app.route("/register", methods=["GET", "POST"])
def register():
if request.method == "POST":
#ensure username was submitted
name = request.form.get("userus")
password = request.form.get("password")
confpassword = request.form.get("confpassword")
if not name:
return render_template("register.html")
#ensure password was submitted
elif not password:
return render_template("register.html")
# ensure password was submitted
elif not confpassword:
return render_template("register.html")
# checking database for failure
result = db.execute("INSERT INTO users (name,password) VALUES(:name,:haspass)", name=request.form.get("inputName"),
#haspass=CryptContext.hash(request.form.get("password")) )
haspass=pwd_context.hash(request.form.get("password")) )
if not result:
return render_template("register.html", nom1=name, nom2=password, nom3=confpassword)
#redirect user to home page
return render_template("register.html", nom1=name, nom2=password, nom3=confpassword)
else:
return render_template("register.html")
I use bootstrap validator (1000hz) you can see it in HTML code and all my imports (everything I found in pset7,8
from cs50 import SQL
from flask import Flask, flash, redirect, render_template, request, session,
url_for, jsonify
from flask_session import Session
from passlib.apps import custom_app_context as pwd_context
from tempfile import mkdtemp
from functools import wraps
from flask_jsglue import JSGlue
import os
import re
Found one just maby interesting thing:
It can see submited values, but I dont know how to pass them to python
Help me to pass these values (name and password) to python or should I just delete bootstrap validation?