Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ ENV LANG ja_JP.utf8
ENV TZ=Asia/Tokyo

WORKDIR /app
COPY . /app
RUN yarn install
CMD ["node", "index.js"]
Empty file added [internal]
Empty file.
14 changes: 14 additions & 0 deletions enquetes.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
doctype html
html(lang="ja")
head
meta(charset="UTF-8")
title アンケートフォーム
body
hi アンケート一覧
ul
li
a(href="/enquetes/yaki-tofu") 焼き肉・湯豆腐
li
a(href="/enquetes/rice-bread") ごはん・パン
li
a(href="/enquetes/sushi-pizza") 寿司・ピザ
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ const server = http
'Content-Type': 'text/html; charset=utf-8'
});

switch (req.method) {
switch (req.method) {
case 'GET':
if (req.url === '/enquetes/yaki-tofu') {
if (req.url === '/') {
res.write(pug.renderFile('./top.pug'))
} else if (req.url === '/enquetes') {
res.write(pug.renderFile('./enquetes.pug'))
} else if (req.url === '/enquetes/yaki-tofu') {
res.write(
pug.renderFile('./form.pug', {
path: req.url,
Expand Down Expand Up @@ -64,7 +68,7 @@ const server = http
.on('clientError', e => {
console.error(`[${new Date()}] Client Error`, e);
});
const port = 8000;
const port = process.env.PORT || 8000;
server.listen(port, () => {
console.info(`[${new Date()}] Listening on ${port}`);
});
8 changes: 8 additions & 0 deletions top.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
doctype html
html(lang="ja")
head
meta(charset="UTF-8")
title アンケートフォーム
body
h1 アンケートフォーム
a(href="/enquetes") アンケート一覧
Loading