Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
孊ぶ Creating Your First Server | Section
Building APIs with Express.js

Creating Your First Server

メニュヌを衚瀺するにはスワむプしおください

To start using Express, you first need to install it in your project.

In your project folder, run:

npm install express

After installation, you can create a basic server.

const express = require("express");

const app = express();

app.listen(3000, () => {
  console.log("Server is running on port 3000");
});

Here's what happens in this code:

You import Express and create an application using express(). Then you start the server using app.listen().

The number 3000 is the port where your server will run. When the server starts, it listens for incoming requests on that port.

To run the server, execute your file with Node.js. If everything works, you will see the message in the terminal.

At this point, the server is running, but it does not handle any requests yet. That will be added in the next step.

question mark

What does app.listen(3000) do?

正しい答えを遞んでください

すべお明確でしたか

どのように改善できたすか

フィヌドバックありがずうございたす

セクション 1. 章 2

AIに質問する

expand

AIに質問する

ChatGPT

䜕でも質問するか、提案された質問の1぀を詊しおチャットを始めおください

some-alt