added request log

This commit is contained in:
CHIEFSOFT\ameye
2024-12-15 00:18:16 -05:00
parent d27ef9e23e
commit 541120fcb7
2 changed files with 56 additions and 9 deletions
+54 -8
View File
@@ -5,6 +5,9 @@ from functools import wraps
import datetime
import jwt
import random
import json
import psycopg2.extras
import pandas as pd
import project.validate.validate as validate
#import project.models.members as Members
@@ -21,6 +24,13 @@ from flask import (
request,
)
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import create_engine
#import SQLAlchemy
#from werkzeug.utils import secure_filename
load_dotenv()
@@ -52,6 +62,7 @@ app.config['SWAGGER'] = {
Swagger(app, template=template)
@swag_from('../../docs/consume.yml')
def token_required(f):
@wraps(f)
def decorated(*args, **kwargs):
@@ -81,6 +92,8 @@ class User(db.Model):
dataUrl = os.getenv("DATABASE_URL")
connection = psycopg2.connect(dataUrl)
#engine = SQLAlchemy.create_engine(dataUrl)
engine = create_engine(dataUrl)
@app.route("/")
def hello_world():
@@ -102,15 +115,43 @@ def hello_world():
{"no": "3", "description": "Web Traffic Analysis" , "date": "10-12-2010 11:30 AM", "status": 'verifying'},
]
}
return jsonify(action_data=action_data)
# 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")
# # return {"account": account}
GLOBAL_AVG = """SELECT * FROM members WHERE id > 0;"""
result = pd.read_sql(GLOBAL_AVG, engine)
print(result)
cols = result.columns.difference(['Col1'])
d = (result.groupby('Col1')[cols]
.apply(lambda x: x.to_dict('r'))
.reset_index(name='Other_details')
.to_json(orient='records'))
#json_data = [json.loads(row[0]) for row in result]
with connection:
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
cursor.execute(GLOBAL_AVG)
account = cursor.fetchall()
print(account[0]["uid"])
# for row in account.rows:
# print(row['id'], row['uid'])
# print(account)
# # Convert the list of tuples to a list of JSON objects
# json_data = [json.loads(row[0]) for row in account]
# #print(account)
# json_data = json.dumps(account)
# print(json_data)
# connection.close()
return jsonify(result=account, action_data=action_data, account=account)
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")
# return {"account": account}
@app.route("/panel/auth/login", methods=["POST"])
@@ -269,7 +310,12 @@ def account_payments(current_user):
@app.route("/panel/myproduct/dash")
@token_required
def myproduct(current_user):
product_id = request.args.get('product_id')
print(product_id)
myproduct_data = {
"myproduct_uid":"",
"banner": "p4.jpg",
"description": "Commitment is something that comes from understanding that everything has its price and then having the willingness to pay that price. This is important because nobody wants to put significant effort into something, only to find out after the fact that the price was too high.The price is something not necessarily defined as financial. It could be time, effort, sacrifice, money or perhaps, something else.",
"title": "Open EMR",
+2 -1
View File
@@ -8,4 +8,5 @@ pyjwt
pillow
flask-cors
pandas
flasgger
flasgger
sqlalchemy