Add admin endpoint uncache.
This commit is contained in:
parent
d61f504d60
commit
6dd4cfe59b
3 changed files with 35 additions and 0 deletions
|
@ -41,3 +41,15 @@ def post_reload_config():
|
||||||
|
|
||||||
common.P.load_config()
|
common.P.load_config()
|
||||||
return flasktools.json_response({})
|
return flasktools.json_response({})
|
||||||
|
|
||||||
|
@site.route('/admin/uncache', methods=['POST'])
|
||||||
|
def post_uncache():
|
||||||
|
if not request.is_localhost:
|
||||||
|
return flasktools.json_response({}, status=403)
|
||||||
|
|
||||||
|
with common.P.transaction:
|
||||||
|
for cache in common.P.caches.values():
|
||||||
|
print(cache)
|
||||||
|
cache.clear()
|
||||||
|
|
||||||
|
return flasktools.json_response({})
|
||||||
|
|
|
@ -10,6 +10,13 @@ function reload_config(callback)
|
||||||
return common.post(url, null, callback);
|
return common.post(url, null, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
api.admin.uncache =
|
||||||
|
function uncache(callback)
|
||||||
|
{
|
||||||
|
const url = "/admin/uncache";
|
||||||
|
return common.post(url, null, callback);
|
||||||
|
}
|
||||||
|
|
||||||
/**************************************************************************************************/
|
/**************************************************************************************************/
|
||||||
api.albums = {};
|
api.albums = {};
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<h1>Admin tools</h1>
|
<h1>Admin tools</h1>
|
||||||
<p><button id="reload_config_button" class="green_button" onclick="return reload_config_form();">Reload config file</button></p>
|
<p><button id="reload_config_button" class="green_button" onclick="return reload_config_form();">Reload config file</button></p>
|
||||||
|
<p><button id="uncache_button" class="green_button" onclick="return uncache_form();">Uncache objects</button></p>
|
||||||
<p><a href="/admin/dbdownload">Download database file</a></p>
|
<p><a href="/admin/dbdownload">Download database file</a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -44,5 +45,20 @@ function reload_config_form()
|
||||||
}
|
}
|
||||||
return api.admin.reload_config(callback);
|
return api.admin.reload_config(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function uncache_form()
|
||||||
|
{
|
||||||
|
const uncache_button = document.getElementById("uncache_button");
|
||||||
|
uncache_button.disabled = true;
|
||||||
|
function callback(response)
|
||||||
|
{
|
||||||
|
uncache_button.disabled = false;
|
||||||
|
if (response.meta.status !== 200)
|
||||||
|
{
|
||||||
|
alert(JSON.stringify(response));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return api.admin.uncache(callback);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue