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

adding 404 webpage #38

Merged
merged 1 commit into from
Mar 13, 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
11 changes: 10 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,19 @@ async function main() {
app.get('/room/:experimentId', validateToken, async (req, res) => {
const params = req.user
const userId = params.userId
// Check if token parameter matches url
if (params.experimentId != req.params.experimentId) {
console.log('[WARN] token experimentId and url do not match!')
res.status(404).sendFile(__dirname + '/webpage_templates/404.html')
return
}

// Check if experiment exists
params.experimentId = req.params.experimentId
const exp = experiments[params.experimentId]
if (!exp || !exp.enabled){
res.status(404).send()
console.log(`[WARN] experiment ${params.experimentId} not found!`)
res.status(404).sendFile(__dirname + '/webpage_templates/404.html')
return
}
const user = usersDb.get(userId) || new User(userId, params.experimentId)
Expand Down
49 changes: 49 additions & 0 deletions webpage_templates/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<title>Waiting Room</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<style>
.container {
display: flex;
justify-content: center;
align-items: center;
}

.loader {
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
width: 120px;
height: 120px;
-webkit-animation: spin 2s linear infinite; /* Safari */
animation: spin 2s linear infinite;
}

.timer {
text-align: center;
font-size: 60px;
margin-top: 0px;
}

/* Safari */
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}

@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>

<body>
<div class="w3-container">
<div id="404Div" class="w3-center w3-margin">
<p>Oops something went wrong!!!</p>
</div>
</div>
</body>
</html>