Skip to content
Sign upLog in
← Back to Community
freeCodeCamp
Profile icon
leandronowras

Basic Node and Express - Start a Working Express Server
In the first two lines of the file myApp.js, you can see how easy it is to create an Express app object. This object has several methods, and you will learn many of them in these challenges. One fundamental method is app.listen(port). It tells your server to listen on a given port, putting it in running state. For testing reasons, we need the app to be running in the background so we added this method in the server.js file for you.

Let’s serve our first string! In Express, routes takes the following structure: app.METHOD(PATH, HANDLER). METHOD is an http method in lowercase. PATH is a relative path on the server (it can be a string, or even a regular expression). HANDLER is a function that Express calls when the route is matched. Handlers take the form function(req, res) {...}, where req is the request object, and res is the response object. For example, the handler

Voters
Profile icon
leandronowras
Comments
hotnewtop
Profile icon
HEMLANU

wow good I have made a game of battleships - https://repl.it/talk/share/War-Battleship/112130 pls see this no one seeing that I took many time to make pls see it