
Photo by
arayan12
勉強ノート:Node.jsのWEBサーバーでindex.htmlを表示させる(Windows10)
前回のexampleフォルダをVScodeで開き、新しいファイルとしてindex.htmlを作る。

ファイル画面で!を書いてタブを押すと、次のように出る。

結果。

言語設定を英語から日本語に変える

server.jsファイルを書き換えてindex.htmlを表示するようにする。
Node.jsのライブラリfsをrequireする。

続けてreadFileSyncを書く。

index.htmlを指定する。

<h1>タグの所をhtmlに書き換える。

res.writeの部分を定数htmlに書き換える。

サーバーを一度停止させてから、前回とおなじくstartさせる。

これでindex.htmlの内容がlocalhost:8000に表示される
