I am new in programming and I know that are useful things out there like wtforms for this, but I want to practice a little before dive into it.
The idea is to create a web app that register the user, and I think it is better to keep this logic apart from the application code.
The problem is that I have this error message: TypeError: register() takes 0 positional arguments but 3 were given I am confused because the function declaration has positional arguments, the code I wrote is:
app code:
@app.route("/register", methods=["POST", "GET"])
def register():
if request.method =="POST":
if not user_name or not password or not pass_confirm:
return ("all fields are mandatory, also consider to active javaScript for a better expirience",404)
user_name = request.form.get("user_name")
password = request.form.get("password")
pass_confirm = request.form.get("user_name")
register(user_name, password, pass_confirm)
return render_template("/register.html")```
in another file:
def register(user_name, password, pass_confirm):
if password != pass_confirm:
return("Password and password confirmation must match")
registerfunction doesn't have positional arguments. Maybe rename the one in the other file toregister_logicor something.