34 lines
949 B
Python
34 lines
949 B
Python
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("/")
|