From 8df6af5edfbf23adefdbe5cd8e046f3e0825132c Mon Sep 17 00:00:00 2001 From: Karl Date: Tue, 15 Jul 2025 11:38:50 +0100 Subject: [PATCH] rework --- .bumpversion.toml | 11 ++++++----- app.py | 2 +- backend/app.py | 19 ------------------- backend/lib/mysql.py | 37 ------------------------------------- config.py.sample | 4 ++++ lib/reqs.py | 19 ------------------- requirements.txt | Bin 246 -> 198 bytes 7 files changed, 11 insertions(+), 81 deletions(-) delete mode 100644 backend/app.py delete mode 100644 backend/lib/mysql.py diff --git a/.bumpversion.toml b/.bumpversion.toml index ae82566..8efc0f0 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -1,8 +1,9 @@ -[tool.bumpversion] -current_version = "1.2.7" +[bumpversion] +current_version = "0.1.0" commit = true tag = true -tag_name = "{new_version}" -[[tool.bumpversion.files]] -filename = "VERSION" \ No newline at end of file +[[bumpversion::file]] +filename = "VERSION" +search = "{current_version}" +replace = "{new_version}" \ No newline at end of file diff --git a/app.py b/app.py index ef41221..cb64634 100644 --- a/app.py +++ b/app.py @@ -4,7 +4,7 @@ from flask_caching import Cache import requests.auth import os from lib.datetime import filter_accounts_next_30_days, filter_accounts_expired -from lib.reqs import get_urls, get_user_accounts, add_user_account, delete_user_account, get_user_accounts_count, get_stream_names +from lib.reqs import get_urls, get_user_accounts, add_user_account, delete_user_account, get_stream_names from flask import send_from_directory import requests import base64 diff --git a/backend/app.py b/backend/app.py deleted file mode 100644 index b711923..0000000 --- a/backend/app.py +++ /dev/null @@ -1,19 +0,0 @@ -from flask import Flask, jsonify -from config import DevelopmentConfig -from lib.mysql import execute_query - -app = Flask(__name__) -app.config.from_object(DevelopmentConfig) - -@app.route('/getUserAccounts', methods=['GET']) -def get_user_accounts(): - # Use the execute_query function to get user accounts - - data = execute_query("SELECT COUNT(*) AS account_count FROM userAccounts WHERE userID = %s;", (1,)) - if data is None: - return jsonify({"error": "Database query failed"}), 500 - return jsonify(data), 200 - -# Run the app -if __name__ == '__main__': - app.run(debug=app.config["DEBUG"], port=app.config["PORT"]) diff --git a/backend/lib/mysql.py b/backend/lib/mysql.py deleted file mode 100644 index 6279714..0000000 --- a/backend/lib/mysql.py +++ /dev/null @@ -1,37 +0,0 @@ -import mysql.connector -from flask import current_app - -def execute_query(query, params=None, fetch_one=False): - """Execute a SQL query and optionally fetch results.""" - try: - # Get database configuration from the current app context - db_config = { - "host": current_app.config['DBHOST'], - "user": current_app.config['DBUSER'], - "password": current_app.config['DBPASS'], - "database": current_app.config['DATABASE'], - } - - # Establish database connection - connection = mysql.connector.connect(**db_config) - cursor = connection.cursor(dictionary=True) - - # Execute the query with optional parameters - cursor.execute(query, params) - - # Fetch results if it's a SELECT query - if query.strip().upper().startswith("SELECT"): - result = cursor.fetchone() if fetch_one else cursor.fetchall() - else: - # Commit changes for INSERT, UPDATE, DELETE - connection.commit() - result = cursor.rowcount # Number of affected rows - - # Close the database connection - cursor.close() - connection.close() - - return result - except mysql.connector.Error as err: - print("Error: ", err) - return None diff --git a/config.py.sample b/config.py.sample index 863df00..30ba662 100644 --- a/config.py.sample +++ b/config.py.sample @@ -3,6 +3,10 @@ class Config: DEBUG = False BASE_URL = '' # Set your base URL here + HOST = '0.0.0.0' + PORT = 5000 + OCR_ENABLED = False + TEXT_INPUT_ENABLED = False class DevelopmentConfig(Config): DEBUG = True diff --git a/lib/reqs.py b/lib/reqs.py index 3f8290f..5dad4cf 100644 --- a/lib/reqs.py +++ b/lib/reqs.py @@ -88,25 +88,6 @@ def add_user_account(base_url: str, auth: str, username: str, password: str, str return response.status_code == 200 -def get_user_accounts_count(base_url: str, auth: str) -> int: - """Get the count of user accounts from the specified base URL. - - Args: - base_url (str): The base URL of the API. - auth (str): The authorization token for accessing the API. - - Returns: - int: The count of user accounts. - """ - url = f"{base_url}/getUserAccounts/count" - payload = {} - headers = {"Authorization": f"Basic {auth}"} - - response = requests.request("GET", url, headers=headers, data=payload) - res_json = json.loads(response.text) - return res_json['count'] - - def get_stream_names(base_url: str, auth: str) -> List[str]: """Get a list of stream names from the API. diff --git a/requirements.txt b/requirements.txt index 5e67647b9759c845136233448c8e80cfd883af9c..e37a2d42720295005cafacd55e2693fc7cfcbb5f 100644 GIT binary patch delta 9 Qcmeyyc#LtviitPm02depegFUf delta 53 zcmX@c_>FPG3hi8mN`_*FLWUd$U4~?ae1<$AOa-z^fb1fmSOHMJgdqbYGjXvp0D##I Ab^rhX