added dash call
This commit is contained in:
@@ -118,17 +118,6 @@ def start_login():
|
|||||||
"error": "Unauthorized"
|
"error": "Unauthorized"
|
||||||
}, 404
|
}, 404
|
||||||
|
|
||||||
|
|
||||||
# GLOBAL_AVG = """SELECT * FROM members WHERE id = 1;"""
|
|
||||||
# with connection:
|
|
||||||
# with connection.cursor() as cursor:
|
|
||||||
# cursor.execute(GLOBAL_AVG)
|
|
||||||
# account = cursor.fetchone()
|
|
||||||
# #return jsonify(hello="ameye world")
|
|
||||||
# token = jwt.encode({'user': 'account', 'exp' : datetime.datetime.utcnow() + datetime.timedelta(minutes=30)},app.config['SECRET_KEY'] )
|
|
||||||
# # return {"account": account}
|
|
||||||
# return {"token": token}
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return {
|
return {
|
||||||
"message": "Something went wrong!",
|
"message": "Something went wrong!",
|
||||||
@@ -151,14 +140,24 @@ def start_resetpass():
|
|||||||
@app.route("/panel/account")
|
@app.route("/panel/account")
|
||||||
@token_required
|
@token_required
|
||||||
def panel_account(current_user):
|
def panel_account(current_user):
|
||||||
member_dash = Members().get_member_by_uid(current_user.user.uid)
|
# print(current_user["user"]["uid"])
|
||||||
print(member_dash)
|
user_uid = current_user["user"]["uid"]
|
||||||
|
# print(user_uid)
|
||||||
|
member_dash = Members().get_member_by_uid(user_uid)
|
||||||
|
print(member_dash[0])
|
||||||
|
print(member_dash[0][0])
|
||||||
return jsonify(hello=current_user)
|
return jsonify(hello=current_user)
|
||||||
|
|
||||||
@app.route("/panel/account/dash")
|
@app.route("/panel/account/dash")
|
||||||
@token_required
|
@token_required
|
||||||
def dashboard():
|
def dashboard():
|
||||||
return jsonify(hello="ameye world")
|
dash_data = {
|
||||||
|
"username": "sanyaameye",
|
||||||
|
"account_name": "This is the test account name",
|
||||||
|
"firstname": "TestFirstname",
|
||||||
|
"lastname": "TestLastname"
|
||||||
|
}
|
||||||
|
return jsonify(dash_data=dash_data)
|
||||||
|
|
||||||
@app.route("/panel/account/products")
|
@app.route("/panel/account/products")
|
||||||
@token_required
|
@token_required
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from dotenv import load_dotenv
|
|||||||
from werkzeug.security import generate_password_hash, check_password_hash
|
from werkzeug.security import generate_password_hash, check_password_hash
|
||||||
import psycopg2
|
import psycopg2
|
||||||
from psycopg2.extras import NamedTupleCursor
|
from psycopg2.extras import NamedTupleCursor
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
@@ -25,10 +26,20 @@ class Members:
|
|||||||
|
|
||||||
def get_member_by_uid(self, user_uid):
|
def get_member_by_uid(self, user_uid):
|
||||||
"""Get a user by uid"""
|
"""Get a user by uid"""
|
||||||
user = db.members.find_one({"uid": user_uid, "active": True})
|
#user = db.members.find_one({"uid": user_uid, "active": True})
|
||||||
if not user:
|
GLOBAL_AVG = "SELECT username,email,account_name,firstname,lastname FROM members WHERE uid::text = '" + user_uid + "'"
|
||||||
|
#print(GLOBAL_AVG)
|
||||||
|
with db:
|
||||||
|
with db.cursor() as cursor:
|
||||||
|
cursor.execute(GLOBAL_AVG)
|
||||||
|
account = cursor.fetchall()
|
||||||
|
#return jsonify(hello="ameye world")
|
||||||
|
# Convert to DataFrame
|
||||||
|
df = pd.DataFrame(account, columns=[desc[0] for desc in db.description])
|
||||||
|
print(df)
|
||||||
|
if not account:
|
||||||
return
|
return
|
||||||
return user
|
return account
|
||||||
|
|
||||||
|
|
||||||
# def get_by_id(self, user_id):
|
# def get_by_id(self, user_id):
|
||||||
|
|||||||
@@ -7,3 +7,4 @@ python-dotenv
|
|||||||
pyjwt
|
pyjwt
|
||||||
pillow
|
pillow
|
||||||
flask-cors
|
flask-cors
|
||||||
|
pandas
|
||||||
Reference in New Issue
Block a user