Skip to content

added date of birth #62

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.DS_Store
.DS_Store
package-lock.json
examples/node_modules/
gordonramsay/node_modules
1 change: 1 addition & 0 deletions examples/hello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("Hello World")
14 changes: 14 additions & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "examples",
"version": "0.1.0",
"description": "Starting off with express",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "[email protected]",
"license": "ISC",
"dependencies": {
"express": "^4.18.2"
}
}
26 changes: 26 additions & 0 deletions examples/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const express = require('express')
const app = express()

app.get('/', function(req, resp){
resp.send('Hello everybody');
})

app.get('/bob/b', function(req, resp){
resp.send('Hello builder');
})

app.get('/random/:max', function(req, resp){
max = parseInt(req.params.max)
rand = Math.floor(Math.random()*max) +1
console.log('Max via url is ' + max + ' rand is ' + rand)
resp.send('' + rand)
})

app.get('/r', function(req, resp){
max = parseInt(req.query.max)
rand = Math.floor(Math.random()*max) +1
console.log('Max via query is ' + max + ' rand is ' + rand)
resp.send('' + rand)
})

app.listen(8090)
8 changes: 8 additions & 0 deletions examples/webserver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
http = require("http")

http.createServer(function (request, response) {
response.writeHead(200, );
response.end('Hello World\n');
}).listen(8080);

console.log('Server running at http://127.0.0.1:8080/');
2 changes: 1 addition & 1 deletion gordonramsay/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<main>
<h1 class="text-body-emphasis">Gordon Ramsay</h1>
<p class="fs-5 col-md-8">Played Aussie football for St Kilda</p>
<img src="https://i.pinimg.com/736x/47/34/cf/4734cf5e9b61c2d8f7f2561c93968c86.jpg" alt="Picture of the wrong Gordon Ramsay">

<div class="mb-5">
<a href="../examples/" class="btn btn-primary btn-lg px-4">Download examples</a>
</div>
Expand Down
16 changes: 16 additions & 0 deletions gordonramsay/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "gordonramsay",
"version": "0.1.0",
"description": "Aussie sportsperson",
"main": "server.js",
"scripts": {
"start": "nodemon server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.18.2",
"nodemon": "^3.0.1"
}
}
24 changes: 24 additions & 0 deletions gordonramsay/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const express = require('express');
const app = express();

let facts = [
{"text": "He played for St. Kilda", "tags": ["geography", "history"]},
{"text": "Was born in 1929", "tags": ["history"]},
{"text": "Is not famous for cookery", "tags": ["friday"]}
];

app.get("/fact", function(request, response){
let factNo = parseInt(request.query.n);
response.send(facts[factNo].text);
});

app.get("/tags", function(request, response){
let tags = [];
for(let fact of facts){
tags = tags.concat(fact.tags)
}
let tagSet = new Set(tags);
response.send([...tagSet])
})

app.listen(8090);