Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added custom 404 error page #831

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 %}
Loading