From 91a973dde24a3308dcb6055a6f0d54fbc19ebe1f Mon Sep 17 00:00:00 2001 From: Bradley Bickford Date: Sun, 9 Nov 2025 21:28:10 -0500 Subject: [PATCH] Some more stuff sort of working, started slideshow stuff --- .../configure_stream/configure_stream.html | 34 +++++++++++++ .../configure_stream/configure_stream.py | 33 ++++++++++++ blueprints/home/home.html | 2 +- blueprints/upload_photo/upload_photo.py | 8 +++ .../upload_slideshow/upload_slideshow.html | 46 +++++++++++++++++ .../upload_slideshow/upload_slideshow.py | 48 ++++++++++++++++++ sc_database_generator.py | 3 +- sc_webserver.py | 3 ++ scdb.db | Bin 24576 -> 24576 bytes 9 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 blueprints/configure_stream/configure_stream.html create mode 100644 blueprints/configure_stream/configure_stream.py create mode 100644 blueprints/upload_slideshow/upload_slideshow.html create mode 100644 blueprints/upload_slideshow/upload_slideshow.py diff --git a/blueprints/configure_stream/configure_stream.html b/blueprints/configure_stream/configure_stream.html new file mode 100644 index 0000000..6dee3b6 --- /dev/null +++ b/blueprints/configure_stream/configure_stream.html @@ -0,0 +1,34 @@ + + + + Video Commander + + + + + + +
+

Configure a Remote Stream

+
+ +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/blueprints/configure_stream/configure_stream.py b/blueprints/configure_stream/configure_stream.py new file mode 100644 index 0000000..dcf842c --- /dev/null +++ b/blueprints/configure_stream/configure_stream.py @@ -0,0 +1,33 @@ +from flask import Blueprint, request, render_template, redirect +from utilities.tools import get_db + +configure_stream_bp = Blueprint('configure_stream', __name__, url_prefix='/configure', template_folder='.') + +@configure_stream_bp.route('/stream', methods=['GET', 'POST']) +def get_page(): + if request.method == "GET": + return render_get() + elif request.method == "POST": + return upload() + + +def render_get(): + return render_template('configure_stream.html'), 200 + +def upload(): + # TODO Input Validation + + new_id = get_db().insert( + "media", + ["media_name", "media_uri"], + [request.form["buttonName"], request.form["streamURL"]] + ) + + if request.form.get("fullScreen", False): + get_db().insert( + "media_playback_option", + ["media_id", "media_playback_option", "media_playback_option_weight"], + [new_id, "-fs", 1] + ) + + return redirect("/") diff --git a/blueprints/home/home.html b/blueprints/home/home.html index 5a18cfb..05d1193 100644 --- a/blueprints/home/home.html +++ b/blueprints/home/home.html @@ -28,7 +28,7 @@

Add Something

Upload a Static Image - + Configure a Stream
diff --git a/blueprints/upload_photo/upload_photo.py b/blueprints/upload_photo/upload_photo.py index 20b6557..7972e7e 100644 --- a/blueprints/upload_photo/upload_photo.py +++ b/blueprints/upload_photo/upload_photo.py @@ -1,4 +1,5 @@ from flask import Blueprint, request, render_template, jsonify, current_app +from utilities.tools import get_db from werkzeug.utils import secure_filename import os @@ -35,6 +36,13 @@ def upload(): filename = secure_filename(file.filename) file.save(os.path.join(folder_path, filename)) + + get_db().insert( + "media", + ["media_name", "media_uri"], + [request.form["name"], os.path.join(folder_path, filename)] + ) + return jsonify({ 'status': 'SUCCESS' }), 200 \ No newline at end of file diff --git a/blueprints/upload_slideshow/upload_slideshow.html b/blueprints/upload_slideshow/upload_slideshow.html new file mode 100644 index 0000000..ad913d6 --- /dev/null +++ b/blueprints/upload_slideshow/upload_slideshow.html @@ -0,0 +1,46 @@ + + + + Video Commander + + + + + + + + +
+

Upload a Slideshow of Photos

+
+ +
+
+
0%
+
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/blueprints/upload_slideshow/upload_slideshow.py b/blueprints/upload_slideshow/upload_slideshow.py new file mode 100644 index 0000000..c334c2c --- /dev/null +++ b/blueprints/upload_slideshow/upload_slideshow.py @@ -0,0 +1,48 @@ +from flask import Blueprint, request, render_template, jsonify, current_app +from utilities.tools import get_db +from werkzeug.utils import secure_filename +import os + +upload_photo_bp = Blueprint('upload_slideshow', __name__, url_prefix='/upload', template_folder='.') + +@upload_photo_bp.route('/slideshow', methods=['GET', 'POST']) +def get_page(): + if request.method == "GET": + return render_get(), 200 + elif request.method == "POST": + return upload() + +def render_get(): + return render_template('upload_slideshow.html') + +def upload(): + if not request.files['files[]']: + return jsonify({ + 'status': 'FAILED', + 'error': '/upload/slideshow requires 1 or more photos' + }), 400 + + # TODO Button name data exists + # TODO Button name already exists validation + # TODO File input validation + print(request.files['files[]']) + + file = request.files['files[]'] + + if file: + folder_path = os.path.join(current_app.config["config"]["upload_location"], request.form["name"]) + if not os.path.exists(folder_path): + os.makedirs(folder_path) + + filename = secure_filename(file.filename) + file.save(os.path.join(folder_path, filename)) + + get_db().insert( + "media", + ["media_name", "media_uri"], + [request.form["name"], os.path.join(folder_path, filename)] + ) + + return jsonify({ + 'status': 'SUCCESS' + }), 200 \ No newline at end of file diff --git a/sc_database_generator.py b/sc_database_generator.py index c5c2486..f169f79 100644 --- a/sc_database_generator.py +++ b/sc_database_generator.py @@ -41,8 +41,9 @@ my_db.query(""" my_db.query(""" CREATE TABLE IF NOT EXISTS media_playback_option ( media_playback_option_id INTEGER PRIMARY KEY AUTOINCREMENT, + media_id INTEGER NOT NULL, media_playback_option TEXT NOT NULL, - media_playback_option_weight NOT NULL CHECK(media_playback_option_weight >= 1) + media_playback_option_weight INTEGER NOT NULL CHECK(media_playback_option_weight >= 1) ) """) diff --git a/sc_webserver.py b/sc_webserver.py index 9c23fee..5d7e6c2 100644 --- a/sc_webserver.py +++ b/sc_webserver.py @@ -1,6 +1,7 @@ from flask import Flask from blueprints.home.home import home_bp from blueprints.upload_photo.upload_photo import upload_photo_bp +from blueprints.configure_stream.configure_stream import configure_stream_bp import os import json @@ -11,9 +12,11 @@ if not os.path.exists(config_json["upload_location"]): os.makedirs(config_json["upload_location"]) app = Flask(__name__) +app.config["MAX_CONTENT_LENGTH"] = 3 * (1024 ** 3) app.config["config"] = config_json app.register_blueprint(home_bp) app.register_blueprint(upload_photo_bp) +app.register_blueprint(configure_stream_bp) if __name__ == '__main__': app.run(debug=True, host="0.0.0.0", port=2025) \ No newline at end of file diff --git a/scdb.db b/scdb.db index 2f3b37e00813e342b487169394bc2699ccefd3c7..1bf26f175c816cfb003e74f896dfa7f9325dd319 100644 GIT binary patch delta 301 zcmZoTz}Rqrae_1>$3z)taSjH(vTj}m1_oBn8V0^rK4YE$uFIS?8ynd;xtc;)*~QJx z8C%>ZZ{%D)Ifq+$as-zPyQg1>tGjE^=Gk1CtX$0ebqxHc_?Ph4Z59+L;ICI6sOI2c(OIE6WN(~1FnpitTX delta 88 zcmZoTz}Rqrae_1>%S0JxaTW%>vTj}m1_oBn