Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'Routes' and 'Express' frameworks to the server #26

Closed
chenbachar opened this issue Jan 25, 2016 · 0 comments
Closed

Add 'Routes' and 'Express' frameworks to the server #26

chenbachar opened this issue Jan 25, 2016 · 0 comments

Comments

@chenbachar
Copy link
Owner

Route definition takes the following structure:

app.METHOD(PATH, HANDLER)

Where:

  • app is an instance of express.
  • METHOD is an HTTP request method.
  • PATH is a path on the server.
  • HANDLER is the function executed when the route is matched.

The following examples illustrate defining simple routes.
Respond with Hello World! on the homepage:
app.get('/', function (req, res) { res.send('Hello World!'); });

Respond to POST request on the root route (/), the application’s home page:
app.post('/', function (req, res) { res.send('Got a POST request'); });

Respond to a PUT request to the /user route:
app.put('/user', function (req, res) { res.send('Got a PUT request at /user'); });

Respond to a DELETE request to the /user route:
app.delete('/user', function (req, res) { res.send('Got a DELETE request at /user'); });

Reference: http://expressjs.com/en/starter/basic-routing.html

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant