expressについて

はじめに

var express = require(“express”);
var app = express();

listen

var server = app.listen(3000, function(){
    console.log(“Node.js is listening to PORT:” + server.address().port);
});

パス

app.get(“/api/photo/:photoId”, function(req, res, next){
    console.log(req.params.photoId);
});

HTMLの表示

ejsを使う

app.set(‘view engine’, ‘ejs’);

パス

app.get(“/”, function(req, res, next){
    res.render(“index”, {}); // 2個目の{} はテンプレートエンジンに渡すobject
});

80番ポートで動かすには

nodeでは8000番ポート、nginxでは80番ポート

Fatal error: Uncaught Error: Call to undefined function set_post_views() in /home/jszk/desnote.com/public_html/wpjs/wp-content/themes/the-thor-child/single.php:658 Stack trace: #0 /home/jszk/desnote.com/public_html/wpjs/wp-includes/template-loader.php(78): include() #1 /home/jszk/desnote.com/public_html/wpjs/wp-blog-header.php(19): require_once('/home/jszk/desn...') #2 /home/jszk/desnote.com/public_html/index.php(17): require('/home/jszk/desn...') #3 {main} thrown in /home/jszk/desnote.com/public_html/wpjs/wp-content/themes/the-thor-child/single.php on line 658