API Stuff

This commit is contained in:
OusmBlueNinja
2025-06-26 09:49:34 -05:00
parent 53af3956d9
commit d26a347d58
3 changed files with 44 additions and 1 deletions

12
app.py
View File

@@ -383,6 +383,18 @@ def news():
return render_template("news.html")
@app.route('/api/check', methods=['POST'])
@login_required
def api_check():
is_outdated = check_outdated()
return jsonify({
"outdated": is_outdated,
"latest": remote_version.strip(),
"current": local_version.strip()
})
@app.route('/settings', methods=['GET', 'POST'])
@login_required
def settings():

View File

@@ -190,6 +190,37 @@
</form>
</div>
<div id="update-check" style="margin-top: 1rem;">
<button class="btn btn-primary" onclick="checkForUpdate()">Check for Updates</button>
<div id="update-result" style="margin-top: 0.5rem;"></div>
</div>
<script>
function checkForUpdate() {
const resultDiv = document.getElementById("update-result");
resultDiv.innerHTML = "Checking...";
fetch("/api/check", {
method: "POST",
headers: {
"Content-Type": "application/json"
}
})
.then(response => response.json())
.then(data => {
if (data.outdated) {
resultDiv.innerHTML = `<span class="text-danger">New version available: ${data.latest}</span>`;
} else {
resultDiv.innerHTML = `<span class="text-success">You're up to date! (${data.latest})</span>`;
}
})
.catch(err => {
resultDiv.innerHTML = `<span class="text-warning">Update check failed.</span>`;
});
}
</script>
<div class="section">
<h2>Create New User</h2>
<form method="POST">

View File

@@ -1 +1 @@
dev-202506260945
dev-202506260949