diff --git a/README.md b/README.md index c413540..43ad0be 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/aperisolve/app.py b/aperisolve/app.py index a66cf9e..8f070f0 100644 --- a/aperisolve/app.py +++ b/aperisolve/app.py @@ -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.""" diff --git a/aperisolve/cleanup.py b/aperisolve/cleanup.py index be77581..48ea6a6 100644 --- a/aperisolve/cleanup.py +++ b/aperisolve/cleanup.py @@ -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() diff --git a/aperisolve/static/css/aperisolve.css b/aperisolve/static/css/aperisolve.css index 79fd981..1d4c7be 100644 --- a/aperisolve/static/css/aperisolve.css +++ b/aperisolve/static/css/aperisolve.css @@ -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; } \ No newline at end of file diff --git a/aperisolve/templates/error.html b/aperisolve/templates/error.html new file mode 100644 index 0000000..903cef3 --- /dev/null +++ b/aperisolve/templates/error.html @@ -0,0 +1,8 @@ +{% extends 'base.html' %} +{% block body_content %} +
+

{{ statuscode }}

+
+

{{ message }}

+
+{% endblock %} \ No newline at end of file