雑多な技術系メモ

自分用のメモ。内容は保証しません。よろしくお願いします。

Expressでアプリ作成する時のメモ

expressの始め方

expressでプロジェクトを作成

express app --view=ejs

参考

https://qiita.com/tsuyoshioshima/items/7a553c25f222333b9503

htmlで、javascriptのコードを呼ぶ時

htmlからjavascriptを呼びだす時のサンプル

/view/index.html

<html>
<body>
<h1> Samle </h1>
<button onclick="sample()">ボタン</button>
<script type="text/javascript" src="/javascripts/index.js"></script>
</body>
</html>

/public/javascripts/index.js

function sample() {
    var text = 'Hello World';
    console.log( text );
}

参考

https://garafu.blogspot.jp/2017/04/nodejs-express-regist.html#confirm.ejs