Web Development Flashcards

1
Q

For the following HTTP request, what line of code will be launched on the server?

POST/login HTTP/1.1

  • app.post(‘/login’, …)
  • app.post(‘/login/:id’, …)
  • app.delete(‘/users/:id’, …)
  • app.get(‘/login’, …)
A

app.post(‘/login’, …)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

In the following list, please check what is NOT an existing HTTP method:

  • PUT
  • GET
  • DELETE
  • CHANGE
A

Change

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the total number of ports available on a server?

  • 128 000
  • 64 000
  • 65 536
  • 128 796
A

65 536 (from 0-65535)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the ‘well-known ports” you cannot use for your own server becase they are reserved for web services?
* 0 to 1023
* 1024 to 49151
* 800 to 2048
* 8080 to 65535

A

0 to 1023, for example well known ports: 443 https, 80 http, 21 jtp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What famous name is associated with IP address 127.0.0.1?
* host-local
* hostlocal
* local-host
* localhost

A
  • localhost

localhost or loopback is your own computer. If you can “ping 127.0.0.1”, it means TCP/IP is up and running on your own computer!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Considering the HTML and CSS codes given:

<div>
My website is cool!
</div>

—————————————————————#textgreen {
color: green;
}

.textred {
color: red;
}
—————————————————————What is the color of the line -My website is cool!-?
* green
* A mix between red and green
* red
* violet

A

green,
the ID has higher priority than the class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Considering the HTML code given:

<div>
My website is <span>cool</span>!
</div>

What is the simplest possible code to make the text -cool- orange?

  • .textred span { color: orange; }
  • .textorange { color: orange; }
  • # textorange { color: orange; }
  • # textgreen span { color: orange; }
A

textorange { color: orange; }

Direct and simple!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Considering the HTML and CSS codes given:

<div>
<span>This text is in
a frame...</span>
</div>

.framedtext {
border: 3px solid red;
}

The result is not satisfying because the text touches the border. I want to add a 8px space between the border and the text, which alternative is correct?

  • border-radius: 8px;
  • box-sizing: border-box;
  • margin: 8px;
  • padding: 8px;
A

padding: 8px;

Padding is the gap between a border and a box content.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A function that you declare in a Javascript program but you do not call yourself is called:

  • A callback function
  • A standalone function
  • A system call function
  • A basic function
A

A callback function
It is “called back” when a certain event occurs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the text needed to replace ZZZ in the following code to get the list of index and role:

app.get(‘/roles2’, function (req, res) {
const persons=[
{“id”: “1”, “name”:”Mira”, “role”: “Lab Assistant”}, {“id”: “2”, “name”:”Susanne”, “role”: “Lecturer”}, {“id”: “3”, “name”:”Jasmin”, “role”: “Lecturer”}, {“id”: “4”, “name”:”Linus”, “role”: “Lecturer, Lab Assistant”}, {“id”: “5”, “name”:”Jerome”, “role”: “Lecturer, Lab Assistant”}
]

myText = “”
persons.forEach( ( ZZZ ) => {
myText += “<li>“+p.id+”: “+p.name+”</li>”
})
res.send(“<ul>“+myText+”</ul>”)
})

The expected result:
* 1: Mira
* 2: Susanne
* 3: Jasmin
* 4: Linus
* 5: Jerome

Select one alternative to replace ZZZ:
*myText
*roles
*p
*persons

A

p, We use p.id and p.name, so it is “p” that must be used in the forEach

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

In my code, I want to extract all the fields (I have five fields in my table) from the table -projects-, what is the good code to execute to get the answer?

*db.all(“SELECT * FROM projects”, (error, theProjects) => { … })
* db.all(“SELECT projID, projName FROM projects”, (error, theProjects) => {…})
* db.run(“SELECT projID, projName FROM projects”, (error, theProjects) => {…})
* db.all(“SELECT * FROM Projects”, (error, theProjects) => {…})

A
  • db.all(“SELECT * FROM projects”, (error, theProjects) => {…})

The table name is case sensitive!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the correct code to change the year to “2023” of my project number (projectId) 4?

  • UPDATE projects SET projectYear=”2023” WHERE project=4
  • UPDATE projects SET projectYear=”2023” WHERE projectId=4
    *UPDATE projects/4 SET projectYear=”2023”
    *UPDATE projects SET projectYear=”2023”
A
  • UPDATE projects SET projectYear=”2023” WHERE projectId=4
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

If you delete your node_modules directory and you want to reinstall all the needed packages for your application. In which file npm will find the packages to install when the command “npm install” is run in the terminal?

  • package.json
  • main.handlebars
  • package-lock.json
  • app.js
A

package.json

This file contains all the dependencies of your project!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Where are the packages installed when you use “npm install nameOfPackage”?

  • Node-Modules/
  • Node_Modules/
  • node_modules/
  • node-modules/
A
  • node_modules/

The name contains only lowercase letters!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Consider the following code:

app.get(‘/’, (req, res) => {
res.render(‘home’);
})

Rewrite the code with the function notation instead of the => notation

A

app.get(‘/’, function(req, res){
res.render(‘home’);
});

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

var port = 8080
const app = express();
var port = 3333
app.listen(port, () => {
console.log(Server listening on port ${port})
})
Write the EXACT text (be careful of upper case and lower case characters in the string) written on the console when the program is run here:

A

Server listening on port 3333

Last defined value

17
Q

app.use((req, res, next) => {
console.log(“Req. URL: “, req.url)
next()
})

What is this full code called?

  • A component
  • A middleware
  • A callback function
  • A central function
A
  • A middleware
    A function that will be called automatically at each coming request
18
Q

We consider we ask the user the id of the project he/she wants to see using a form. This id is put in the variable pid. Why does the following code is a security issue?

db.run(“SELECT * FROM projects WHERE id=”+pid, (error) => {
if(error) {console.log(“ERROR: “, error) }
else { console.log(“I got the result from the projects table!”)}
})

  • The pid is not a number
  • The pid is a number
  • The pid is empty
  • The pid can contain a string with corrupted inserted SQL code
A

The pid can contain a string with corrupted inserted SQL code

That is why we have the “?” notation when we write a parameter in our SQL queries!