Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialtal Shnitzer
Courses Plus Student 5,242 Pointswho is making the request from the server we have created?
who is making the request from the server? we have created a server that is getting a request and answer with a response. the reponse is shown on treehouse port 3000. but I don't understand: at this stage - who is making the request? how the request is being issued?
5 Answers
andren
28,558 PointsYou, or more accurately your browser (Chrome, Firefox, Safari, etc) is the one making the request by the very act of visiting the URL.
When you tell your browser to connect to a page it uses a protocol called HTTP to send a GET request to the server which asks it to send back data. Once the server receives the request, it looks at what page was requested and runs code to fetch and prepare the data needed to display the page. Then it sends a response back to your browser, which your browser then renders for you.
That explanation is a bit simplified since I don't want to get too technical, but it should give you a general understanding. And Treehouse does have some courses centered on this topic, specifically How the Internet Works, How the Web Works and the workshop HTTP: Do you GET it?.
tal Shnitzer
Courses Plus Student 5,242 Pointsthanks. so when I've clicked on the workspace right corner "eye" button, I've actually asked to get treehouse on port 3000?
andren
28,558 PointsYes, the URL Treehouse generates forwards your request to port 3000 on your current workspace.
tal Shnitzer
Courses Plus Student 5,242 Pointsthanks. would you happen to also know by any chance what will happen when I'll run it from my own computer, not using the workspaces? I've installed the node.js and run command line app through terminal. there was no need for a browser. who will generated the URL and the request when I'll run it locally? even while I ask this question it sounds to me like the browser should do it, but how?
andren
28,558 PointsIf you ran the project from this course on a locally installed version of Node.js it would start a web server on your local machine.
There would be no domain name pointing at the server but domain names (like teamtreehouse.com
) are actually just labels for IP Addresses, which is what computers on the internet actually use to connect to each other. So it's not actually needed to connect to a server, as you can connect to it directly using its IP Address.
Specifically you can connect to it by going to the following URL in your browser: http://127.0.0.1:3000
That address (127.0.0.1
) is a special address that always points to the machine it is used on, and the :3000
part is how you tell your browser what port to connect to.
Web development with Node.js is usually done using a framework called Express, the syntax for that is a bit different from what is shown in this video, but that also starts a web server on your machine which you can connect to in the same way as shown above.
I have done a decent amount of programming in Node.js and Express, so if you have any further questions about those or anything else brought up in this post then feel free to ask them.
tal Shnitzer
Courses Plus Student 5,242 Pointsgreat, thanks. I might have after trying to run it locally ,when I'll finish this course. You've beed a great help
andren
28,558 PointsNo problem .
tal Shnitzer
Courses Plus Student 5,242 Pointsworking locally. great!
andren
28,558 PointsThat's good to hear .