0
0

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 3 years have passed since last update.

[node.js] 簡易HttpServer

Posted at
  • ソースコード
    • GET/POST関係なく同じレスポンスを返します。
    • 色々分岐したければ、req の内容を見て判定すればよい。
httpServer.js
const http = require('http');
http.createServer().on('request', function(req, res) {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.write('Hello world\n');
    res.end();
}).listen(8000);
  • 起動
$ node httpServer.js
  • 停止
    • Ctrl+c で停止。
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?