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
12 changes: 12 additions & 0 deletions axiosdemo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

const axios = require("axios").default;

const url = "http://localhost:3000/";

const resultingPromise = axios.get(url);

resultingPromise.then(printLogResultsOfGet);

function printLogResultsOfGet(result) {
console.log(result.data);
}
29 changes: 29 additions & 0 deletions dbdemoapp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const express = require('express');

const { makeDBConnectionPool } = require("./dbhelp");

const pool = makeDBConnectionPool("omdb");

const app = express();

let movieList = []

app.listen(3000)

app.get('/',(request, response) =>{
response.json(movieList);
});

function displayMovies(movieRows) {
for (let row of movieRows) {
movieList.push(row.movie_name);
}
return movieList;
}
function arrayofMovies(){
pool.query("select movie_name from casts_view where person_name = 'Tom Hardy'").then((results) => {
displayMovies(results.rows);
});
}

arrayofMovies();
14 changes: 14 additions & 0 deletions dbhelp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { Pool } = require("pg");

/**
*Makes a pool of connections to the named database. it is assumed the db is on localhost.
* @param {string} dbName name of database to connect to
*/
function makeDBConnectionPool(dbName) {
//Understanding the details is not important here.
return new Pool({
database: dbName,
});
}

module.exports = { makeDBConnectionPool };
25 changes: 25 additions & 0 deletions dieroll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const express = require('express');

const app = express();

app.listen(3000)

app.get('/roll1',(request, response) =>{
response.send('Your dice roll is:' + randomDieRoll1())
});

app.get('/roll2',(request, response) =>{
response.send('Your dice roll is:' + totalDiceRoll())
});

function randomDieRoll1(){
return 1 + Math.floor((Math.random() * 6))
}

function randomDieRoll2(){
return 1 + Math.floor((Math.random() * 6))
}

function totalDiceRoll(){
return randomDieRoll1() + randomDieRoll2()
}
16 changes: 16 additions & 0 deletions html/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<body>
<header>
<</header>
<main id="main">
<link rel="stylesheet" href="styles.css">
<h1 id="title">About Me</h1>
<p>About Me Page</p>




</main>
</body>
</html>
42 changes: 42 additions & 0 deletions html/nolansite.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html>
<body>
<header>
<h3><a href="https://tomis-first-website.netlify.app">Previous Site</a> </h3>
<h3><a href="https://ty-hafan-tribute.netlify.app/">Next Site</a></h3>
</header>
<main id="main">
<link rel="stylesheet" href="styles.css">
<h1 id="title">Christopher Nolan</h1>
<p>The worlds Greatest Director?</p>
<figure id="img-div">
<img id="image" src="https://www.shutterstock.com/image-photo/christopher-nolan-attends-screening-sink-600nw-1104452255.jpg" alt="Christopher Nolan in a tux">
<figcaption id="img-caption">
Christopher Nolan attending a premiere of one of his films.
</figcaption>
</figure>
<section id="tribute-info">
<h3 id="headline">Here is a list of Christopher Nolan's films</h3>
<ul>
<li>Memento (2000)</li>
<li>Batman Begins (2005)</li>
<li>The Presige (2006)</li>
<li>The Dark Knight (2008)</li>
<li>Inception (2010)</li>
<li>The Dark Knight Rises (2012)</li>
<li>Interstellar (2014)</li>
<li>Dunkirk (2017)</li>
<li>Tenet (2020)</li>
<li>Oppenheimer (2023)</li>
<p>I find it very hard to chose favouorite films but in the interests of making this website I will give my top 3 Christopher Nolan films in order. </p>
<ol reversed>
<li> Batman Begins - the re-birth of the Batman franchise this film was cooler than cool.</li>
<li> The Dark Knight - Heath Ledger as the Joker, enough said.</li>
<li> Inception - am I dreaming? No this is just the best Nolan film to date.</li>
</ol>
<p>Find out more about Christpoher Nolan from this <a id="tribute-link" href="https://en.wikipedia.org/wiki/Christopher_Nolan" target="_blank">link</a></p>


</main>
</body>
</html>
9 changes: 9 additions & 0 deletions jsonapp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const express = require('express');

const app = express();

app.listen(3000)

app.get('/',(request, response) =>{
response.json(['ross','lauren','neill'])
});
13 changes: 13 additions & 0 deletions rosscoapp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const express = require('express');

const app = express();

app.listen(3000)

app.get('/',(request, response) =>{
response.sendFile('./html/nolansite.html', { root: __dirname});
});

app.get('/about',(request, response) =>{
response.sendFile('./html/about.html', { root: __dirname});
});
21 changes: 21 additions & 0 deletions rosscoserver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const http = require("http");
const fs = require("fs");

const server = http.createServer((request, result) => {
console.log("request made");
result.setHeader("Content-Type", "text/html");

fs.readFile("./html/nolansite.html", (error, data) => {
if (error) {
console.log(error);
result.end();
} else {
result.write(data);
result.end();
}
});
});

server.listen(3000, "localhost", () => {
console.log("listening for requests");
});