/panel/account/bar

This commit is contained in:
CHIEFSOFT\ameye
2024-12-21 16:51:33 -05:00
parent 5bdbd9540d
commit c4feec6374
+77 -2
View File
@@ -26,7 +26,7 @@ from flask import (
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import create_engine
import socket
#import SQLAlchemy
@@ -43,6 +43,8 @@ db = SQLAlchemy(app)
app.config['SECRET_KEY'] = os.getenv("JWT_SECRET")
#print( "aaaa-bbbb--ccccc" )
#print( jwt_secret )
SOCKET_URL = os.getenv("SOCKET_URL") # The server's hostname or IP address
print(SOCKET_URL)
template = {
"swagger": "2.0",
@@ -62,6 +64,9 @@ app.config['SWAGGER'] = {
Swagger(app, template=template)
@swag_from('../../docs/consume.yml')
# client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# # client_socket.connect((os.getenv("SOCKET_URL"), 80))
# # client_socket.send('hello from server')
def token_required(f):
@wraps(f)
@@ -338,6 +343,24 @@ def panel_products(current_user):
}
return jsonify(products_data=products_data)
@app.route("/panel/account/bar")
@token_required
def recent_actions(current_user):
bar_data = {
"last_update": datetime.datetime.utcnow(),
"initial": random.randint(0, 10),
"processing": random.randint(0, 10),
"verifying" : random.randint(0, 10),
"completed" : random.randint(0, 10),
"top_bar": [
{"id": "1", "description": "Contacts" , "last_update": "10-10-2010 11:00 AM", "value": '0' , "data_span":'Last 2 months'},
{"id": "2", "description": "Site Traffic" , "last_update": "10-10-2010 11:30 AM", "value": '0', "data_span":'Past 12 hours'},
{"id": "3", "description": "Appointments" , "last_update": "10-12-2010 11:30 AM", "value": '0', "data_span":'Last 14 days'},
{"id": "4", "description": "Purchases" , "last_update": "10-12-2010 11:30 AM", "value": '0', "data_span":'Last 3 months'},
]
}
return jsonify(bar_data=bar_data)
@app.route("/panel/account/actions")
@token_required
def recent_actions(current_user):
@@ -421,4 +444,56 @@ def myproduct(current_user):
"price_text" : "90 days free and 3.95/Month",
}
return jsonify(myproduct_data=myproduct_data)
return jsonify(myproduct_data=myproduct_data)
# PORT = 65432 # The port used by the serv
@app.route("/panel/socket/send")
def socket_connect_send():
print(SOCKET_URL)
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(('10.0.0.32', 5005))
print( "HERE 002:")
while 1:
data = client_socket.recv(512)
print( "HERE 003: " , data)
if ( data == 'q' or data == 'Q'):
print( "HERE 001:")
client_socket.close()
break;
else:
print( "RECIEVED:" , data)
data = raw_input ( "SEND( TYPE q or Q to Quit):" )
if (data != 'Q' and data != 'q'):
client_socket.send(data)
else:
client_socket.send(data)
client_socket.close()
break;
#
# with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
# s.connect(("10.0.0.32", 5005))
# while 1:
# data = s.recv(512)
# if ( data == 'q' or data == 'Q'):
# s.close()
# break;
# else:
# print "RECIEVED:" , data
# data = raw_input ( "SEND( TYPE q or Q to Quit):" )
# if (data <> 'Q' and data <> 'q'):
# s.send(data)
# else:
# s.send(data)
# s.close()
# break;
# # s.emit('join', 'room1');
# s.join('room1')
# s.sendall(b"Hello, world")
# data = s.recv(1024)
# print(f"ConRes {res!r}")
# print(f"Received {data!r}")
return jsonify(socket_end="socket_call")