Merge pull request #76 from Zeecka/main

Fix 500 and custom 404
This commit is contained in:
Zeecka
2025-06-15 18:22:08 +02:00
committed by GitHub
5 changed files with 28 additions and 0 deletions
+2
View File
@@ -74,6 +74,8 @@ Here is a batch of usefull commands.
docker compose down -v # Remove volume containings results
docker compose -f docker-compose-dev.yml up # Start application in developpement mode
rm -rf aperisolve/results # Remove results from developpement mode
docker exec -it postgres psql -U aperiuser -d aperisolve # Get postgresql shell
docker exec -it aperisolve-web bash # Get shell in running web app
```
> Note, if you used [docker-compose-dev.yml](docker-compose-dev.yml), you must remove "results" when switching to [production docker](docker-compose.yml).
+6
View File
@@ -38,6 +38,12 @@ def too_large(_: Any) -> tuple[Response, int]:
return jsonify({"error": "Image size exceeded"}), 413
@app.errorhandler(404)
def not_found(_: Any) -> str:
"""Error Handler for 404 not found."""
return render_template("error.html", message="Ressource not found", statuscode=404)
@app.route("/")
def index() -> str:
"""Render the main index page."""
+5
View File
@@ -47,4 +47,9 @@ def cleanup_old_entries() -> None:
shutil.rmtree(RESULT_FOLDER / img.hash) # type: ignore
db.session.delete(img)
# Delete Images with missing submission
if len(img.submissions) == 0 and delay > MAX_PENDING_TIME:
shutil.rmtree(RESULT_FOLDER / img.hash) # type: ignore
db.session.delete(img)
db.session.commit()
+7
View File
@@ -407,4 +407,11 @@ footer a i {
.glow-border {
border: 1px solid var(--theme-green);
box-shadow: 0 0 10px var(--theme-green-shadow);
}
#httperror{
padding-top: 100px;
}
#httperror h1, #httperror h2{
text-align: center;
}
+8
View File
@@ -0,0 +1,8 @@
{% extends 'base.html' %}
{% block body_content %}
<div id="httperror">
<h1>{{ statuscode }}</h1>
<br>
<h2>{{ message }}</h2>
</div>
{% endblock %}