「node.js入門」require()でhttpモジュールを使うサンプル

2020年11月23日

構文
var http = require(“http");
http.createServer(function(request, response)
{some code}
サンプルコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
var http = require("http");
function onRequest(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("welcome study in arkgame");
response.end();
}
http.createServer(onRequest).listen(8080);
var http = require("http"); function onRequest(request, response) { response.writeHead(200, {"Content-Type": "text/plain"}); response.write("welcome study in arkgame"); response.end(); } http.createServer(onRequest).listen(8080);
var http = require("http");

function onRequest(request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.write("welcome study in arkgame");
  response.end();
}

http.createServer(onRequest).listen(8080);

 

Node.js

Posted by arkgame