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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Rocket Academy Coding Bootcamp: Video Poker

Published via Netlify: https://videopoker-ame.netlify.app/
34 changes: 34 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>🃑 Poker 🃑</title>
<link rel="stylesheet" href="styles.css" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Bubblegum+Sans&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
crossorigin="anonymous"
/>
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
charset="utf-8"
/>
</head>

<body>
<h1 id="header">🂡 Poker 🂡</h1>
<!-- Import program logic -->
<script src="./src/gameInit.js"></script>
<script src="./src/tally.js"></script>
<script src="./src/pokerRules.js"></script>
<script src="./src/testHands.js"></script>
<script src="./src/gamePlay.js"></script>
<script src="src/audio.js"></script>
</body>
</html>
48 changes: 48 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { createServer } from 'http';
import { readFile } from 'fs';
import path from 'path';

const PORT = process.argv[2];

const whenIncomingRequest = (request, response) => {
// request.url contains the portion of the URL after the domain.
// E.g. for https://ra.co/index.html, request.url would return "/index.html".
console.log("request url", request.url);
// "." refers to the Unix filesystem ".", which represents the current directory.
const filePath = "." + request.url;
var extname = String(path.extname(filePath)).toLowerCase();
var mimeTypes = {
".html": "text/html",
".txt": "text/plain",
".js": "text/javascript",
".css": "text/css",
".json": "application/json",
".png": "image/png",
".jpg": "image/jpg",
".gif": "image/gif",
".svg": "image/svg+xml",
".wav": "audio/wav",
".mp3": "audio/mp3",
".mp4": "video/mp4",
".woff": "application/font-woff",
".ttf": "application/font-ttf",
".eot": "application/vnd.ms-fontobject",
".otf": "application/font-otf",
".wasm": "application/wasm",
};

var contentType = mimeTypes[extname] || "application/octet-stream";

readFile(filePath, (err, content) => {
if (err) {
console.error("error reading file", err);
return;
}
// Set the response code to 200 (i.e. OK)
response.writeHead(200, { "Content-Type": contentType });
// Send the response with the file content in utf-8 format
response.end(content, "utf-8");
});
};

createServer(whenIncomingRequest).listen(PORT)
Loading