Skip to content
Open
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
5 changes: 5 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ def method_not_allowed(error):
"""Render a friendly 405 page when the wrong HTTP method is used."""
return render_template("405.html"), 405

@app.errorhandler(403)
def forbidden(error):
"""Render a friendly 403 page when access is denied."""
return render_template("403.html"), 403


if __name__ == "__main__":
# debug=True is only for local development.
Expand Down
25 changes: 25 additions & 0 deletions templates/403.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Forbidden — DevPath</title>
<link rel="stylesheet" href="/static/style.css" />
<link href="https://fonts.googleapis.com/css2?family=Sora:wght@400;600;700;800&family=Inter:wght@400;500&display=swap" rel="stylesheet" />
</head>
<body>
<nav class="navbar">
<div class="nav-inner">
<a href="/" class="nav-logo">DevPath</a>
</div>
</nav>
<div class="error-page">
<div class="error-page-inner">
<div class="error-code">403</div>
<h1>Forbidden</h1>
<p>You do not have permission to access this page.</p>
<a href="/" class="btn-primary" style="display:inline-block;text-decoration:none;padding:14px 32px;">Back to Home</a>
</div>
</div>
</body>
</html>
Loading