Some more stuff sort of working, started slideshow stuff
This commit is contained in:
parent
d332aca22e
commit
91a973dde2
34
blueprints/configure_stream/configure_stream.html
Normal file
34
blueprints/configure_stream/configure_stream.html
Normal file
@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Video Commander</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../static/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1 class="text-center">Configure a Remote Stream</h1>
|
||||
<hr>
|
||||
<div class="alert alert-info text-center" role="alert">
|
||||
Configure a stream, content that is played from a location on the local network or the Internet.
|
||||
</div>
|
||||
<form action="/configure/stream" method="POST">
|
||||
<div class="form-group">
|
||||
<label for="buttonName">Button Name</label>
|
||||
<input type="text" class="form-control" name="buttonName" id="buttonName" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="streamURL">Stream URL</label>
|
||||
<input type="text" class="form-control" name="streamURL" id="streamURL" />
|
||||
</div>
|
||||
<div class="form-check form-switch form-check-input-lg">
|
||||
<input type="checkbox" class="form-check-input" name="fullScreen" id="fullScreen" checked/>
|
||||
<label for="fullScreen" class="form-check-label">Play the stream in Full Screen?</label>
|
||||
</div>
|
||||
<button id="submit" class="btn btn-primary form-control" type="submit">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
33
blueprints/configure_stream/configure_stream.py
Normal file
33
blueprints/configure_stream/configure_stream.py
Normal file
@ -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("/")
|
||||
@ -28,7 +28,7 @@
|
||||
<h3 class="text-center">Add Something</h3>
|
||||
<div class="row">
|
||||
<a class="col-sm-4 btn btn-secondary p-3 my-1" href="/upload/photo">Upload a Static Image</a>
|
||||
<button class="col-sm-4 btn btn-secondary p-3 my-1">Configure a Stream</button>
|
||||
<a class="col-sm-4 btn btn-secondary p-3 my-1" href="/configure/stream">Configure a Stream</a>
|
||||
<button class="col-sm-4 btn btn-secondary p-3 my-1">Upload a Slideshow of Images</button>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
@ -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
|
||||
46
blueprints/upload_slideshow/upload_slideshow.html
Normal file
46
blueprints/upload_slideshow/upload_slideshow.html
Normal file
@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Video Commander</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../static/style.css">
|
||||
<script src="../static/script.js"></script>
|
||||
<script>
|
||||
function prepUpload() {
|
||||
uploadFiles('submit', 'fileToUpload', 'progressContainer', 'progress', '/upload/slideshow', {
|
||||
'name': document.getElementById('buttonName').value
|
||||
})
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1 class="text-center">Upload a Slideshow of Photos</h1>
|
||||
<hr>
|
||||
<div class="alert alert-info text-center" role="alert">
|
||||
Upload a slideshow of photos, you'll be able to order the photos on the next screen
|
||||
</div>
|
||||
<form>
|
||||
<div id="progressContainer" class="progress" role="progressbar", aria-label="Upload Progress" aria-valuemin="0"
|
||||
aria-valuemin="0", aria-valuemax="100" >
|
||||
<div id="progress" class="progress-bar" style="width: 0%;">0%</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="fileToUpload">File to Upload</label>
|
||||
<input type="file" class="form-control" name="file" id="fileToUpload" multiple/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="buttonName">Button Name</label>
|
||||
<input type="text" class="form-control" name="buttonName" id="buttonName" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="photoTime">How long to show each photo?</label>
|
||||
<input type="number" class="form-control" name="photoTime" id="photoTime" />
|
||||
</div>
|
||||
<button id="submit" class="btn btn-primary form-control" onclick="prepUpload()">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
48
blueprints/upload_slideshow/upload_slideshow.py
Normal file
48
blueprints/upload_slideshow/upload_slideshow.py
Normal file
@ -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
|
||||
@ -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)
|
||||
)
|
||||
""")
|
||||
|
||||
|
||||
@ -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)
|
||||
Loading…
Reference in New Issue
Block a user