Page 254 - Nodejs 교과서 개정2판
P. 254
{% endblock %}
</body>
</html>
index.html
{% extends 'layout.html' %}
{% block content %}
<h1>{{title}}</h1>
<p>Welcome to {{title}}</p>
{% endblock %}
error.html
{% extends 'layout.html' %}
{% block content %}
<h1>{{message}}</h1>
<h2>{{error.status}}</h2>
<pre>{{error.stack}}</pre>
{% endblock %}
JOEFY IUNMਸ ࠁݶ {% extends 'layout.html' %}৬ {% block content %}о णפ MBZPVU IUNM {% blo
ck content %} ࠗ࠙ী JOEFY IUNM {% block content %}ܳ ֍णפ JOEFY IUNM res.render۽ࠗఠ titl
eۄח ߸ࣻܳ ߉ই ۪؊݂פ
FSSPS IUNMب {% block content %} ࠗ࠙ MBZPVU IUNMҗ োѾؾפ res.render۽ࠗఠ message৬ error ߸
ࣻܳ ߉ই ۪؊݂פ
ী۞ ܻ ٜਝয
Әө మ݁ ূਸ ಝࠌणפ ઁ ٜਝয৬ ী۞ ܻ ٜਝযܳ җ э ࣻೞৈ
ী۞ ߊࢤ द FSSPS IUNMী ী۞ ղਊਸ दפ
app.js
...
app.use((req, res, next) => {
const error = new Error(`${req.method} ${req.url} 라우터가 없습니다.`);
error.status = 404;
next(error);
});