Need help to implement token based authorization steps and solution. I am using flask as back-end and html and CSS front-end. But i am facing difficulty to find best content about api. my purpose is to build user login and registrations
This is my code
#database MySQL
from flask import Flask, render_template, request, redirect, url_for,jsonify
import db
import datetime
import time
app = Flask(__name__)
cursor, conn = db.connection(app)
@app.route("/")
def index():
return render_template("signup.html", title="SignUp")
@app.route("/signUp", methods = ["POST"])
def signUp():
username=str(request.form["user"])
password = str(request.form["password"])
email = str(request.form["email"])
cursor = conn.cursor()
cursor.execute("INSERT INTO users(name, password, email)VALUES(%s, %s, %s)", (username, password, email))
conn.commit()
conn.close()
return redirect(url_for("login"))
@app.route("/login")
def login():
return render_template("login.html", title="data")
@app.route("/checkUser", methods=["POST"])
def check():
username = str(request.form["user"])
password = str(request.form["password"])
cursor.execute("SELECT * FROM users where name = %s and password=%s", (username, password))
users = cursor.fetchone()
if users is None:
return "username is wrong"
else:
return render_template("home.html")
@app.route("/home")
def home():
return render_template("home.html")
if __name__ == "__main__":``
app.run(debug=True)