validate module

This commit is contained in:
CHIEFSOFT\ameye
2024-12-08 17:49:02 -05:00
parent 935fba5111
commit d76c696420
3 changed files with 49 additions and 25 deletions
+12 -25
View File
@@ -5,6 +5,11 @@ from functools import wraps
import datetime
import jwt
import project.validate.validate as validate
#from models.models import User
from flask import (
Flask,
jsonify,
@@ -12,7 +17,7 @@ from flask import (
request,
)
from flask_sqlalchemy import SQLAlchemy
from werkzeug.utils import secure_filename
#from werkzeug.utils import secure_filename
load_dotenv()
@@ -70,6 +75,12 @@ def start_login():
"data": None,
"error": "Bad request"
}, 400
# validate input
is_validated = validate.validate_username_and_password(data.get('username'), data.get('password'))
if is_validated is not True:
return dict(message='Invalid data', data=None, error=is_validated), 400
GLOBAL_AVG = """SELECT * FROM members WHERE id = 1;"""
with connection:
@@ -120,27 +131,3 @@ def panel_products():
def recent_actions():
return jsonify(hello="ameye world")
@app.route("/static/<path:filename>")
def staticfiles(filename):
return send_from_directory(app.config["STATIC_FOLDER"], filename)
@app.route("/media/<path:filename>")
def mediafiles(filename):
return send_from_directory(app.config["MEDIA_FOLDER"], filename)
@app.route("/upload", methods=["GET", "POST"])
def upload_file():
if request.method == "POST":
file = request.files["file"]
filename = secure_filename(file.filename)
file.save(os.path.join(app.config["MEDIA_FOLDER"], filename))
return """
<!doctype html>
<title>upload new File</title>
<form action="" method=post enctype=multipart/form-data>
<p><input type=file name=file><input type=submit value=Upload>
</form>
"""