Topic 3 Flashcards

1
Q

What are some actions we can perform with the file_system module?

A
  • Create directories and files
  • View directories and files
  • Stream files
  • Read and write files
  • etc.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does it mean when a method is synchronous?

A

The method stops all other operations until this one is finished.

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

What does it mean when a method is asynchronous?

A

Other operations/processes can execute while this one completes itself. When complete, a callback function will be called.

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

How to read and write files?

A

fs.readFile(path, callback(err, data)) and fs.writeFile(etc)

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

How to read a directory?

A

fs.readdir(path, callback(err, files))

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

What is the general purpose of the URL module?

A

To parse URls

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

What is the general form of an URL?

A

Protocol://Domain-name:port/Directory-path/Filename

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

With the URL module we can access information like the…

A

host, protocol, authentication details, query strings, etc

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

The URL has two main constructors. They are

A

The URL class, which allows us to access the data of a URL and…
The URLSearchParams.set/get which allows us to manipulate the query string

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

What is HTTP?

A

A generic, stateless, protocol which can be used for many tasks beyond its use for hypertext, such as name servers and distributed object management systems, through extension of its requests methods ,error codes, and headers.

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

What are the different versions of HTML and when were they introduced and with what features?

A

1991 v0.9 - process static pages
1992 v0.1 - CSS, video/script/img processing
1994 v1.1 - keep-alive + cookies
2012 v2.0 - collaboration + social media

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

________ ___ _____ are created using server side scripts.

A

Dynamic web pages. The scripts processes data that comes from user input and databases.

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

The protocol of a URL defines…

A

the type of protocol used by client and server ex. http, https, ftp

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

The domain name of a URL defines…

A

the web server

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

The port of a URL defines…

A

the port used (default 80)

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

The directory path of a URL defines…

A

the path to the file

17
Q

The filename of a URL defines…

A

the requested file

18
Q

If there is no specified file name, the server will… (3 things)

A
  • Return an error message
  • Provide the default file (usually index.html)
  • Redirect to a default location
19
Q

The HTTP request GET is used to…

A

request a web resource from the server (most common HTTP request)

20
Q

The HTTP request HEAD is used to…

A

get the header that a GET request would obtain. (Used to check against local cache copy, as it contains the date)

21
Q

The HTTP request POST is used to…

A

post data up to the web server

22
Q

The HTTP request PUT is used to…

A

ask the server to store the data

23
Q

The HTTP request DELETE is used to…

A

ask the server to delete the data

24
Q

Which class of HTTP response status codes refer to informational?

A

1xx (server is continuing the process)

25
Q

Which class of HTTP response status codes refer to success?

A

2xx (200 is the all good code)

26
Q

Which class of HTTP response status codes refer to redirection?

A

3xx (further action needed to complete request)

27
Q

Which class of HTTP response status codes refer to client error?

A

4xx

28
Q

Which class of HTTP response status codes refer to server error?

A

5xx

29
Q

A browser distinguishes between different file types using the ____ type.

A

MIME (Multipurpose Internet Mail Extensions). Usually in the form of “type/subtype” ex “text/html”

30
Q

What is the easiest way to make an process HTTP requests?

A

Using the HTTP module.

Use http.request(options, callback(res)) to make a request

31
Q

How do you create a file server?

A

http.createServer(callback(req, res))

Res is the response provided by the server, usually done by using writeHead and end functions.

32
Q

In addition to turning the server on, what other crucial information must you specify?

A

The server must be given a port to listen to.

server.listen(port)