1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

expressを最小構成で試す

Posted at

node.jsだとバックエンドにexpressを利用することが多いと思いますが、プロトタイプ作成など、さっとつくるときの最小構成を試してみます。

$ npm i -S express
'use strict';
const app = new (require('express'))();
const port = 3000;

app.get('/', (req, res) => {
  res.sendFile(__dirname + '/index.html')
});

app.listen(port, error => {
  if (error) {
    console.error(error);
  } else {
    console.info('listen: ', port);
  }
});
index.html
<h1>Hello, Express</h1>
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?