CORRECT VENV AND ACTUALL API & CLI UPDATE.. update

This commit is contained in:
2025-09-18 00:00:18 +03:00
parent d636ab6286
commit 6826e9bedb
63 changed files with 67 additions and 2 deletions

View File

@@ -100,6 +100,26 @@ def tiropit_add_user():
# App version endpoints
@app.route("/api/getTiropitVersion", methods=["GET"])
def getTiropitVersion():
conn = get_db_connection()
cursor = conn.cursor(dictionary=True)
try:
cursor.execute("SELECT Version FROM AppData ORDER BY ID DESC LIMIT 1")
result = cursor.fetchone()
if result:
return jsonify({"Version":result["Version"]}), 200
else:
return jsonify({"error":"No version found"}), 404
except mysql.connector.Error as e:
return jsonify({"error":str(e)}), 500
finally:
cursor.close()
conn.close()
if __name__ == '__main__':
app.run(host="0.0.0.0", port=5000, debug=True)

View File

@@ -23,7 +23,7 @@ class Config():
class ServerObj():
def __init__(self, isReachable=False):
self.host = "0.0.0.0" + ":5000"
self.host = "0.0.0.0"
self.isReachable = False
self.state = "Resolving IP"
@@ -38,6 +38,22 @@ class ServerObj():
args = parser.parse_args()
Server = ServerObj()
class TiropitCliObj:
_server_instance = Server
@property
def url(self):
return f"http://{self._server_instance.host}:5000"
@property
def isReachable(self):
return self._server_instance.isReachable
TiropitCLI = TiropitCliObj()
#declare files
config = configparser.ConfigParser()
configPath = Path("Config.ini")
@@ -90,6 +106,30 @@ def select_folder():
return folder_path
# [Update Functions] <------------------------------------------------------------------------------------------------------------ [Begin]
def CheckForUpdate(log=False):
print("Connecting....")
print(f"Request Version from API@{TiropitCLI.url}")
response = requests.get(TiropitCLI.url + "/api/getTiropitVersion")
print(f"ResponseCode:{response.status_code}")
print(f"ResponseJSON:{response.json()}")
# [Update Functions] <-------------------------------------------------------------------------------------------------------------- [End]
def TiropitLogin():
@@ -107,6 +147,8 @@ def TiropitLogin():
Display.Clear()
showIntroText()
print(f"|[LogIn: Login page] [{Server.Icon}]|")
print("| Enter your username |")
print("| |")
print("| |")
@@ -316,7 +358,7 @@ def showMenu(menuID):
print("|[1] Log in to tiropit | [2] Reset Data & Config |")
print("|[3] Send / Get Request| [4] My Profile |")
print("|[5] Debug Data | [6] Games |")
print("|[e] Exit |")
print("|[e] Exit | [7] Update |")
print("======================================================")
option = input(">> ")
if option == "": showMenu(1)
@@ -328,6 +370,9 @@ def showMenu(menuID):
TiropitLogin()
case "5":
debugMenu()
case "7":
CheckForUpdate()
case "6":
Gamesmenu()
case "e":