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

Handling the error 404 (page not found). #106

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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 @@ -188,6 +188,11 @@ def format_response(response_text):
def index():
return render_template('index.html')

"""Adding 404 error handler page """
@app.errorhandler(404)
def error404(e):
return render_template("error_404.html")


@app.route('/api/weather')
def get_weather():
Expand Down
62 changes: 62 additions & 0 deletions templates/error_404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>404 - Page Not Found</title>

<style>
body {
font-family: Arial, sans-serif;
color: #00dffc;
text-align: center;
background-color: #0a0a0a;
padding: 50px;
background-image: url('path/to/network-background.png');
background-size: cover;
background-attachment: fixed;
}
.container {
max-width: 600px;
margin: auto;
}
h1 {
font-size: 3.5em;
color: #00dffc;
text-shadow: 0 0 8px #00dffc, 0 0 15px #ff007a;
animation: glitch 1.5s infinite;
}
p {
font-size: 1.2em;
color: #ddd;
}
.button {
display: inline-block;
margin-top: 20px;
padding: 10px 20px;
font-size: 1em;
color: #fff;
background: linear-gradient(45deg, #00dffc, #ff007a);
text-decoration: none;
border-radius: 5px;
transition: background 0.3s;
}
.button:hover {
background: linear-gradient(45deg, #ff007a, #00dffc);
}
@keyframes glitch {
0% { text-shadow: 2px 2px #ff007a; }
50% { text-shadow: -2px -2px #00dffc; }
100% { text-shadow: 2px 2px #ff007a; }
}
</style>
</head>
<body>
<div class="container">
<h1>404: Lost in the Network</h1>
<p>The page you're looking for seems to have drifted into cyberspace.</p>
<p><a href="/" class="button">Back to Home</a></p>
<p><a href="/chat" class="button">Explore Our AI Suite</a></p>
</div>
</body>
</html>