diff --git a/documentation.html b/documentation.html new file mode 100644 index 0000000..051ecc5 --- /dev/null +++ b/documentation.html @@ -0,0 +1,14 @@ + + + + Movie API Documentation + + +

Welcome to the Movie API Documentation

+

+ 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. +

+ + diff --git a/index.html b/index.html new file mode 100644 index 0000000..8c54e41 --- /dev/null +++ b/index.html @@ -0,0 +1,11 @@ + + + + + + Document + + +

index - movie api!

+ + diff --git a/log.txt b/log.txt new file mode 100644 index 0000000..b14b106 --- /dev/null +++ b/log.txt @@ -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) + diff --git a/server.js b/server.js new file mode 100644 index 0000000..009acf5 --- /dev/null +++ b/server.js @@ -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."); diff --git a/test.js b/test.js new file mode 100644 index 0000000..557e7a1 --- /dev/null +++ b/test.js @@ -0,0 +1,5 @@ +console.log("Hello Node!"); + +console.log("Goodbye"); + +const bufs = Buffer.from([1, 2, 3, 4]);