aboutsummaryrefslogtreecommitdiffstats
path: root/backend/app.py
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2023-11-18 21:21:22 -0800
committerPinapelz <yukais@pinapelz.com>2023-11-18 21:21:22 -0800
commitadc88dbdf3274d4d0cf15b5f2cf7b0bbb939bfe0 (patch)
tree96089396e548f3f57121674362b6170c7b76693b /backend/app.py
parent96019367e8f72eac26abd3b7a908c2b914bd1ae1 (diff)
v3: re-write frontend using next js
Diffstat (limited to 'backend/app.py')
-rw-r--r--backend/app.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/backend/app.py b/backend/app.py
index 51b0dbb..71ed62a 100644
--- a/backend/app.py
+++ b/backend/app.py
@@ -3,14 +3,28 @@ Flask app for serving the static files
"""
from flask import Flask, send_file, send_from_directory, jsonify, abort
from flask_cors import CORS
+from sql.sql_handler import SQLHandler
+import fileutil as fs
+import datetime
app = Flask(__name__)
+CONFIG = fs.load_config("config.ini")
CORS(app)
-@app.route('/')
-def main_page():
- return "We are offline at the moment"
+@app.route("/")
+def index():
+ return send_file("index.html")
+
+@app.route("/api/subscribers")
+def api_subscribers():
+ server = SQLHandler(CONFIG["SQL"]["host"], CONFIG["SQL"]["user"], CONFIG["SQL"]["password"], CONFIG["SQL"]["database"])
+ data = server.execute_query("SELECT * FROM subscriber_data INNER JOIN 24h_historical ON subscriber_data.channel_id = 24h_historical.channel_id ORDER BY subscriber_count DESC")
+ channel_data_list = [{"channel_name":row[3], "profile_pic": row[2], "subscribers": row[4], "sub_org": row[5], "video_count": row[6], "day_diff": int(row[10] - int(row[4]))} for row in data]
+ subscriber_data = {"timestamp": datetime.datetime.now(),"channel_data":channel_data_list}
+
+ return jsonify(subscriber_data)
+
@app.errorhandler(404)
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage