API Stuff
This commit is contained in:
12
app.py
12
app.py
@@ -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():
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -1 +1 @@
|
||||
dev-202506260945
|
||||
dev-202506260949
|
||||
|
||||
Reference in New Issue
Block a user