A bunch of work getting blueprints working

This commit is contained in:
Bradley Bickford 2025-10-26 19:21:00 -04:00
parent 223a105be4
commit d59e23fc4c
9 changed files with 47 additions and 12 deletions

View File

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <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"> <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> <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"> <link rel="stylesheet" type="text/css" href="../static/style.css">
</head> </head>
<body> <body>
<div class="container"> <div class="container">
@ -27,7 +27,7 @@
<hr> <hr>
<h3 class="text-center">Add Something</h3> <h3 class="text-center">Add Something</h3>
<div class="row"> <div class="row">
<button class="col-sm-4 btn btn-secondary p-3 my-1">Upload a Static Image</button> <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> <button class="col-sm-4 btn btn-secondary p-3 my-1">Configure a Stream</button>
<button class="col-sm-4 btn btn-secondary p-3 my-1">Upload a Slideshow of Images</button> <button class="col-sm-4 btn btn-secondary p-3 my-1">Upload a Slideshow of Images</button>
</div> </div>

11
blueprints/home/home.py Normal file
View File

@ -0,0 +1,11 @@
from flask import Blueprint, request, render_template
home_bp = Blueprint('home', __name__, template_folder='.')
@home_bp.route("/")
def root_route():
if request.method == "GET":
return render_get(), 200
def render_get():
return render_template('home.html')

View File

@ -0,0 +1,15 @@
<!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">Upload a Static Photo</h1>
</div>
</body>
</html>

View File

@ -0,0 +1,11 @@
from flask import Blueprint, request, render_template
upload_photo_bp = Blueprint('upload_photo', __name__, url_prefix='/upload', template_folder='.')
@upload_photo_bp.route('/photo')
def get_page():
if request.method == "GET":
return render_get(), 200
def render_get():
return render_template('upload_photo.html')

View File

@ -2,7 +2,7 @@ import json
from utilities.database.sqlite import SQLite from utilities.database.sqlite import SQLite
with open("config.json", 'r') as config_file: with open("config.json", 'r') as config_file:
config_json = json.load(config_file.read()) config_json = json.loads(config_file.read())
my_db = SQLite(config_json["database"]["name"]) my_db = SQLite(config_json["database"]["name"])
@ -12,7 +12,8 @@ my_db.query("""
media_name TEXT NOT NULL, media_name TEXT NOT NULL,
media_uri TEXT, media_uri TEXT,
media_preparing INTEGER DEFAULT 0 CHECK(media_preparing IN (0, 1)), media_preparing INTEGER DEFAULT 0 CHECK(media_preparing IN (0, 1)),
media_active INTEGER DEFAULT 0 CHECK(media_active IN (0, 1)) media_active INTEGER DEFAULT 0 CHECK(media_active IN (0, 1)),
media_default INTEGER DEFAULT 0 CHECK(media_default IN (0, 1))
) )
""") """)
@ -21,6 +22,7 @@ my_db.query("""
media_preparation_id INTEGER PRIMARY KEY AUTOINCREMENT, media_preparation_id INTEGER PRIMARY KEY AUTOINCREMENT,
media_id INTEGER NOT NULL, media_id INTEGER NOT NULL,
media_preparation_started INTEGER DEFAULT 0 CHECK(media_preparation_started IN (0, 1)), media_preparation_started INTEGER DEFAULT 0 CHECK(media_preparation_started IN (0, 1)),
media_preparation_progress INTEGER,
media_preparation_finished INTEGER DEFAULT 0 CHECK(media_preparation_finished IN (0, 1)), media_preparation_finished INTEGER DEFAULT 0 CHECK(media_preparation_finished IN (0, 1)),
media_preparation_time_between_components INTEGER media_preparation_time_between_components INTEGER
) )

View File

@ -1,14 +1,10 @@
from flask import Flask from flask import Flask
from jinja2 import Template from blueprints.home.home import home_bp
from blueprints.upload_photo.upload_photo import upload_photo_bp
app = Flask(__name__) app = Flask(__name__)
app.register_blueprint(home_bp)
@app.route("/") app.register_blueprint(upload_photo_bp)
def root_route():
with open("./pages/home/resources/home.html", "r") as html_file:
template = Template(html_file.read())
return template.render({}), 200
if __name__ == '__main__': if __name__ == '__main__':
app.run(debug=True, host="0.0.0.0", port=2025) app.run(debug=True, host="0.0.0.0", port=2025)

BIN
scdb.db Normal file

Binary file not shown.

BIN
testdb.db

Binary file not shown.