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
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ RUN localedef -f UTF-8 -i ja_JP ja_JP
ENV LANG ja_JP.UTF-8
ENV TZ Asia/Tokyo
WORKDIR /app
COPY . /app
CMD ["sh", "run.sh"]
16 changes: 14 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@ const server = http

switch (req.method) {
case 'GET':
if (req.url === '/enquetes/yaki-shabu') {
if (req.url === '/') {
res.write('<!DOCUMENT html><html lang="ja"><body>' +
'<h1>アンケートフォーム</h1>' +
'<a href="/enquetes">アンケート一覧</a>' +
'</body></html>');
} else if (req.url === '/enquetes') {
res.write('<!DOCUMENT html><html lang="ja"><body>' +
'<h1>アンケート一覧</h1><ul>' +
'<li><a href="/enquetes/yaki-shabu">焼き肉・しゃぶしゃぶ</a></li>' +
'<li><a href="/enquetes/rice-bread">ごはん・パン</a></li>' +
'<li><a href="/enquetes/sushi-pizza">寿司・ピザ</a></li>' +
'</ul></body></html>');
} else if (req.url === '/enquetes/yaki-shabu') {
res.write(
pug.renderFile('./form.pug', {
path: req.url,
Expand Down Expand Up @@ -63,7 +75,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);
});
2 changes: 2 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
yarn install
node index.js
Loading