Skip to content

Commit

Permalink
Added custom 404 error page (#831)
Browse files Browse the repository at this point in the history
  • Loading branch information
DelfinSR authored Mar 5, 2024
1 parent 7c90d12 commit 24e6568
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@
"code",
"ideas"
]
},
{
"login": "DelfinSR",
"name": "Delfin",
"avatar_url": "https://avatars.githubusercontent.com/u/91948384?v=4",
"profile": "https://github.com/DelfinSR",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Huge thanks to the following people that contributed to Artemis development!
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mimi89999"><img src="https://avatars.githubusercontent.com/u/8530546?v=4?s=100" width="100px;" alt="Michel Le Bihan"/><br /><sub><b>Michel Le Bihan</b></sub></a><br /><a href="https://github.com/CERT-Polska/Artemis/commits?author=mimi89999" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://eliszewski.pl/"><img src="https://avatars.githubusercontent.com/u/565758?v=4?s=100" width="100px;" alt="Grzegorz Eliszewski"/><br /><sub><b>Grzegorz Eliszewski</b></sub></a><br /><a href="https://github.com/CERT-Polska/Artemis/commits?author=es1o" title="Code">💻</a> <a href="#ideas-es1o" title="Ideas, Planning, & Feedback">🤔</a> <a href="#platform-es1o" title="Packaging/porting to new platform">📦</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kshitijk4poor"><img src="https://avatars.githubusercontent.com/u/82637225?v=4?s=100" width="100px;" alt="kshitij kapoor"/><br /><sub><b>kshitij kapoor</b></sub></a><br /><a href="https://github.com/CERT-Polska/Artemis/commits?author=kshitijk4poor" title="Code">💻</a> <a href="#ideas-kshitijk4poor" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/DelfinSR"><img src="https://avatars.githubusercontent.com/u/91948384?v=4?s=100" width="100px;" alt="Delfin"/><br /><sub><b>Delfin</b></sub></a><br /><a href="https://github.com/CERT-Polska/Artemis/commits?author=DelfinSR" title="Code">💻</a></td>
</tr>
</tbody>
</table>
Expand Down
4 changes: 4 additions & 0 deletions artemis/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ def get_binds_that_can_be_disabled() -> List[KartonBind]:
return binds


def error_content_not_found(request: Request, exc: HTTPException) -> Response:
return templates.TemplateResponse("not_found.jinja2", {"request": request}, status_code=404)


@router.get("/", include_in_schema=False)
def get_root(request: Request) -> Response:
karton_state = KartonState(backend=KartonBackend(config=KartonConfig()))
Expand Down
2 changes: 2 additions & 0 deletions artemis/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
from artemis import csrf, db_migration
from artemis.api import router as router_api
from artemis.db import DB
from artemis.frontend import error_content_not_found
from artemis.frontend import router as router_front

app = FastAPI()
app.exception_handler(CsrfProtectError)(csrf.csrf_protect_exception_handler)
app.exception_handler(404)(error_content_not_found)

db = DB()

Expand Down
7 changes: 7 additions & 0 deletions templates/not_found.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends "components/base.jinja2" %}
{% block main %}
<h1>404 - Not Found</h1>
<p>
Content not found.
</p>
{% endblock %}

0 comments on commit 24e6568

Please sign in to comment.