Topic 3 Flashcards
What are some actions we can perform with the file_system module?
- Create directories and files
- View directories and files
- Stream files
- Read and write files
- etc.
What does it mean when a method is synchronous?
The method stops all other operations until this one is finished.
What does it mean when a method is asynchronous?
Other operations/processes can execute while this one completes itself. When complete, a callback function will be called.
How to read and write files?
fs.readFile(path, callback(err, data)) and fs.writeFile(etc)
How to read a directory?
fs.readdir(path, callback(err, files))
What is the general purpose of the URL module?
To parse URls
What is the general form of an URL?
Protocol://Domain-name:port/Directory-path/Filename
With the URL module we can access information like the…
host, protocol, authentication details, query strings, etc
The URL has two main constructors. They are
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
What is HTTP?
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.
What are the different versions of HTML and when were they introduced and with what features?
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
________ ___ _____ are created using server side scripts.
Dynamic web pages. The scripts processes data that comes from user input and databases.
The protocol of a URL defines…
the type of protocol used by client and server ex. http, https, ftp
The domain name of a URL defines…
the web server
The port of a URL defines…
the port used (default 80)
The directory path of a URL defines…
the path to the file
The filename of a URL defines…
the requested file
If there is no specified file name, the server will… (3 things)
- Return an error message
- Provide the default file (usually index.html)
- Redirect to a default location
The HTTP request GET is used to…
request a web resource from the server (most common HTTP request)
The HTTP request HEAD is used to…
get the header that a GET request would obtain. (Used to check against local cache copy, as it contains the date)
The HTTP request POST is used to…
post data up to the web server
The HTTP request PUT is used to…
ask the server to store the data
The HTTP request DELETE is used to…
ask the server to delete the data
Which class of HTTP response status codes refer to informational?
1xx (server is continuing the process)
Which class of HTTP response status codes refer to success?
2xx (200 is the all good code)
Which class of HTTP response status codes refer to redirection?
3xx (further action needed to complete request)
Which class of HTTP response status codes refer to client error?
4xx
Which class of HTTP response status codes refer to server error?
5xx
A browser distinguishes between different file types using the ____ type.
MIME (Multipurpose Internet Mail Extensions). Usually in the form of “type/subtype” ex “text/html”
What is the easiest way to make an process HTTP requests?
Using the HTTP module.
Use http.request(options, callback(res)) to make a request
How do you create a file server?
http.createServer(callback(req, res))
Res is the response provided by the server, usually done by using writeHead and end functions.
In addition to turning the server on, what other crucial information must you specify?
The server must be given a port to listen to.
server.listen(port)