Web Development Flashcards
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’, …)
app.post(‘/login’, …)
In the following list, please check what is NOT an existing HTTP method:
- PUT
- GET
- DELETE
- CHANGE
Change
What is the total number of ports available on a server?
- 128 000
- 64 000
- 65 536
- 128 796
65 536 (from 0-65535)
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
0 to 1023, for example well known ports: 443 https, 80 http, 21 jtp
What famous name is associated with IP address 127.0.0.1?
* host-local
* hostlocal
* local-host
* localhost
- 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!
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
green,
the ID has higher priority than the class
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; }
textorange { color: orange; }
Direct and simple!
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;
padding: 8px;
Padding is the gap between a border and a box content.
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 callback function
It is “called back” when a certain event occurs
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
p, We use p.id and p.name, so it is “p” that must be used in the forEach
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) => {…})
- db.all(“SELECT * FROM projects”, (error, theProjects) => {…})
The table name is case sensitive!
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”
- UPDATE projects SET projectYear=”2023” WHERE projectId=4
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
package.json
This file contains all the dependencies of your project!
Where are the packages installed when you use “npm install nameOfPackage”?
- Node-Modules/
- Node_Modules/
- node_modules/
- node-modules/
- node_modules/
The name contains only lowercase letters!
Consider the following code:
app.get(‘/’, (req, res) => {
res.render(‘home’);
})
Rewrite the code with the function notation instead of the => notation
app.get(‘/’, function(req, res){
res.render(‘home’);
});
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:
Server listening on port 3333
Last defined value
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 middleware
A function that will be called automatically at each coming request
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
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!