Skip to content

Commit

Permalink
Added local repository
Browse files Browse the repository at this point in the history
  • Loading branch information
ffferchavez committed Nov 15, 2023
1 parent e031837 commit 8746cc4
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 deletions.
14 changes: 14 additions & 0 deletions documentation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Movie API Documentation</title>
</head>
<body>
<h1>Welcome to the Movie API Documentation</h1>
<p>
This API provides access to a database of movies. You can retrieve
information about movies, search for movies, and add new movies to the
database.
</p>
</body>
</html>
11 changes: 11 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<h1>index - movie api!</h1>
</body>
</html>
6 changes: 6 additions & 0 deletions log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
URL: /documentation
Timestamp: Wed Nov 15 2023 13:17:22 GMT+0100 (Central European Standard Time)

URL: /favicon.ico
Timestamp: Wed Nov 15 2023 13:17:22 GMT+0100 (Central European Standard Time)

40 changes: 40 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const http = require("http"),
fs = require("fs"),
url = require("url");

http
.createServer((request, response) => {
let addr = request.url,
q = new URL(addr, "http://" + request.headers.host),
filePath = "";

fs.appendFile(
"log.txt",
"URL: " + addr + "\nTimestamp: " + new Date() + "\n\n",
(err) => {
if (err) {
console.log(err);
} else {
console.log("Added to log.");
}
}
);

if (q.pathname.includes("documentation")) {
filePath = __dirname + "/documentation.html";
} else {
filePath = "index.html";
}

fs.readFile(filePath, (err, data) => {
if (err) {
throw err;
}

response.writeHead(200, { "Content-Type": "text/html" });
response.write(data);
response.end();
});
})
.listen(8080);
console.log("My test server is running on Port 8080.");
5 changes: 5 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
console.log("Hello Node!");

console.log("Goodbye");

const bufs = Buffer.from([1, 2, 3, 4]);

0 comments on commit 8746cc4

Please sign in to comment.