Video 14 of Node JS Tutorial, thenewboston
Video Name: Simple Web File Server
- instead of sending data back, we need to send files back
- function onRequest = a function that will listen for functions
- you should make an if statement, saying request.method
- get = standard method of connecting to a website
- request.url, if equal to a /, you are connecting to the home page
- use the command "response.writeHand (200, ("Content-Type": "text/html"});" to send a html file back
- we need to send back a readable stream
- the file could be any size, want to send it back as a stream - used for better performance
- the command "fs.createReadStream("./index.html").pipe(response);
- the pipe function is to write it out, for feed it out
I am having trouble finding a suitable program to use for writing code. For some reason, my node.js file does not work running on these programs like Atom and Webstorm. If there are any suggestions, please do tell me.
- instead of sending data back, we need to send files back
- function onRequest = a function that will listen for functions
- you should make an if statement, saying request.method
- get = standard method of connecting to a website
- request.url, if equal to a /, you are connecting to the home page
- use the command "response.writeHand (200, ("Content-Type": "text/html"});" to send a html file back
- we need to send back a readable stream
- the file could be any size, want to send it back as a stream - used for better performance
- the command "fs.createReadStream("./index.html").pipe(response);
- the pipe function is to write it out, for feed it out
I am having trouble finding a suitable program to use for writing code. For some reason, my node.js file does not work running on these programs like Atom and Webstorm. If there are any suggestions, please do tell me.
No comments:
Post a Comment