Node.js
Node.js
JavaScript
express
Web Application MVC
npm install express --save
var express = require('express');
var app = express();
mkdir sampleNode
cd sampleNode
// package.json
npm init
//
npm install express --save
// application
touch app.js
---- app.js ----
var express = require("express")
var app = express();
app.get("/", function(req, res){
res.send("Hello, World!!");
});
app.listen(process.env.PORT, process.env.IP, function(){
console.log("Server has started!!");
});
Node.js Hello,World!! .
ejs !!
npm install ejs --save
touch landing.ejs
---- app.js ----
var express = require("express");
var app = express();
app.set("view engine", "ejs");
app.get("/", function(req, res){
res.render("landing");
});
app.listen(process.env.PORT, process.env.IP, function(){
console.log("Server has started!!");
});
---- landing.ejs ----
<h1>This is landing page!!</h1>
View
touch mountains.ejs
---- app.js ----
app.get("/mountains", function(req, res){
var mountainArray = [
{name: "Mt.Fuji"}
{name: "Yarigatake"}
{name: "Kumotorisan"}
{name: "Thukubasan"}
{name: "Takaosan"}
]
// {mountains:mountains} view
res.render("mountains"), {mountains:mountainArray};
});
---- mountains.ejs ----
<% mountains.forEach(function(mountain){ %>
<h4><%= mountain.name %></h4>
<% }); %>
JS

More Related Content

PDF
Server Side Apocalypse, JS
PPTX
Introduction to node.js
PDF
CasperJS and PhantomJS for Automated Testing
PPTX
Herramientas front
PDF
CasperJs Enjoy Functional Testing
PDF
Superfast Automated Web Testing with CasperJS & PhantomJS
PDF
Testing MeteorJS using CasperJS
PDF
Site Testing with CasperJS
Server Side Apocalypse, JS
Introduction to node.js
CasperJS and PhantomJS for Automated Testing
Herramientas front
CasperJs Enjoy Functional Testing
Superfast Automated Web Testing with CasperJS & PhantomJS
Testing MeteorJS using CasperJS
Site Testing with CasperJS

What's hot (20)

PDF
ServiceWorker: New game changer is coming!
ODP
Presentation of JSConf.eu
PDF
Node.js in a heterogeneous system
PPTX
Node.js Express
PDF
Future of scripting
PDF
NodeJS: n00b no more
PDF
Build web application by express
KEY
Server side scripting smack down - Node.js vs PHP
PDF
Phantom js quick start
PDF
Angular2 ecosystem
PPTX
When a Sassquatch and a Board get together (or how to use Grunt to chew Sass)
PDF
What Is Async, How Does It Work, And When Should I Use It?
PPT
Владимир Мигуро "Дао Node.js"
PPTX
Node.js Spplication Scaling
PPT
Node.js Cloud deployment
PPTX
Windows Azure loves OSS
PDF
Create a RESTful API with NodeJS, Express and MongoDB
PDF
ModemFrontEndops
PDF
Running node.js as a service behind nginx/varnish
ServiceWorker: New game changer is coming!
Presentation of JSConf.eu
Node.js in a heterogeneous system
Node.js Express
Future of scripting
NodeJS: n00b no more
Build web application by express
Server side scripting smack down - Node.js vs PHP
Phantom js quick start
Angular2 ecosystem
When a Sassquatch and a Board get together (or how to use Grunt to chew Sass)
What Is Async, How Does It Work, And When Should I Use It?
Владимир Мигуро "Дао Node.js"
Node.js Spplication Scaling
Node.js Cloud deployment
Windows Azure loves OSS
Create a RESTful API with NodeJS, Express and MongoDB
ModemFrontEndops
Running node.js as a service behind nginx/varnish
Ad

Similar to Node.jsやってみた (20)

PDF
Node.js in action
PPTX
Building Web Apps with Express
PPTX
Starting with Node.js
PPTX
A Simple Node.pptx that contain node js goir
PDF
Introduction to Node js for beginners + game project
PDF
introduction to node js kndoendenendjndj
PPTX
express-express-express-express-express-
PPTX
ExpressJs Session01
PDF
What is Node.js? (ICON UK)
PPTX
Unit 1 Express J for mean stack and mern
PPT
nodejs tutorial foor free download from academia
PDF
Node intro
PDF
Артем Маркушев - JavaScript
PDF
Introduction to Node.JS Express
KEY
nodecalgary1
KEY
A nodejs application
PDF
PPT
Nodejs quick start
PDF
Basic API Creation with Node.JS
PDF
Node.js - async for the rest of us.
Node.js in action
Building Web Apps with Express
Starting with Node.js
A Simple Node.pptx that contain node js goir
Introduction to Node js for beginners + game project
introduction to node js kndoendenendjndj
express-express-express-express-express-
ExpressJs Session01
What is Node.js? (ICON UK)
Unit 1 Express J for mean stack and mern
nodejs tutorial foor free download from academia
Node intro
Артем Маркушев - JavaScript
Introduction to Node.JS Express
nodecalgary1
A nodejs application
Nodejs quick start
Basic API Creation with Node.JS
Node.js - async for the rest of us.
Ad

Recently uploaded (20)

PPT
12 Things That Make People Trust a Website Instantly
PPTX
newyork.pptxirantrafgshenepalchinachinane
PPTX
IPCNA VIRTUAL CLASSES INTERMEDIATE 6 PROJECT.pptx
PDF
Top 8 Trusted Sources to Buy Verified Cash App Accounts.pdf
PDF
📍 LABUAN4D EXCLUSIVE SERVER STAR GAMING ASIA NO.1 TERPOPULER DI INDONESIA ! 🌟
PDF
mera desh ae watn.(a source of motivation and patriotism to the youth of the ...
PDF
SlidesGDGoCxRAIS about Google Dialogflow and NotebookLM.pdf
PPTX
The-Importance-of-School-Sanitation.pptx
PDF
The Evolution of Traditional to New Media .pdf
PPT
250152213-Excitation-SystemWERRT (1).ppt
PPTX
t_and_OpenAI_Combined_two_pressentations
PPTX
Internet Safety for Seniors presentation
PDF
Course Overview and Agenda cloud security
PDF
Lean-Manufacturing-Tools-Techniques-and-How-To-Use-Them.pdf
PDF
BIOCHEM CH2 OVERVIEW OF MICROBIOLOGY.pdf
PPTX
Layers_of_the_Earth_Grade7.pptx class by
PDF
Alethe Consulting Corporate Profile and Solution Aproach
PDF
Understand the Gitlab_presentation_task.pdf
PDF
Uptota Investor Deck - Where Africa Meets Blockchain
PPTX
Cyber Hygine IN organizations in MSME or
12 Things That Make People Trust a Website Instantly
newyork.pptxirantrafgshenepalchinachinane
IPCNA VIRTUAL CLASSES INTERMEDIATE 6 PROJECT.pptx
Top 8 Trusted Sources to Buy Verified Cash App Accounts.pdf
📍 LABUAN4D EXCLUSIVE SERVER STAR GAMING ASIA NO.1 TERPOPULER DI INDONESIA ! 🌟
mera desh ae watn.(a source of motivation and patriotism to the youth of the ...
SlidesGDGoCxRAIS about Google Dialogflow and NotebookLM.pdf
The-Importance-of-School-Sanitation.pptx
The Evolution of Traditional to New Media .pdf
250152213-Excitation-SystemWERRT (1).ppt
t_and_OpenAI_Combined_two_pressentations
Internet Safety for Seniors presentation
Course Overview and Agenda cloud security
Lean-Manufacturing-Tools-Techniques-and-How-To-Use-Them.pdf
BIOCHEM CH2 OVERVIEW OF MICROBIOLOGY.pdf
Layers_of_the_Earth_Grade7.pptx class by
Alethe Consulting Corporate Profile and Solution Aproach
Understand the Gitlab_presentation_task.pdf
Uptota Investor Deck - Where Africa Meets Blockchain
Cyber Hygine IN organizations in MSME or

Node.jsやってみた

  • 3. express Web Application MVC npm install express --save var express = require('express'); var app = express();
  • 4. mkdir sampleNode cd sampleNode // package.json npm init // npm install express --save // application touch app.js ---- app.js ---- var express = require("express") var app = express(); app.get("/", function(req, res){ res.send("Hello, World!!"); }); app.listen(process.env.PORT, process.env.IP, function(){ console.log("Server has started!!"); }); Node.js Hello,World!! .
  • 5. ejs !! npm install ejs --save touch landing.ejs ---- app.js ---- var express = require("express"); var app = express(); app.set("view engine", "ejs"); app.get("/", function(req, res){ res.render("landing"); }); app.listen(process.env.PORT, process.env.IP, function(){ console.log("Server has started!!"); }); ---- landing.ejs ---- <h1>This is landing page!!</h1>
  • 6. View touch mountains.ejs ---- app.js ---- app.get("/mountains", function(req, res){ var mountainArray = [ {name: "Mt.Fuji"} {name: "Yarigatake"} {name: "Kumotorisan"} {name: "Thukubasan"} {name: "Takaosan"} ] // {mountains:mountains} view res.render("mountains"), {mountains:mountainArray}; }); ---- mountains.ejs ---- <% mountains.forEach(function(mountain){ %> <h4><%= mountain.name %></h4> <% }); %>
  • 7. JS