質問編集履歴
1
ご指摘いただいた内容での変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -51,3 +51,147 @@
|
|
51
51
|
となっています.
|
52
52
|
|
53
53
|
よろしくお願いします.
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
変更した点
|
60
|
+
|
61
|
+
```js
|
62
|
+
|
63
|
+
let app = require("http").createServer(handler);
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
'use strict'; <- 解答通りにいれてみました
|
68
|
+
|
69
|
+
app.listen(process.env.PORT || 3000);
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
function handler(req, res) {
|
74
|
+
|
75
|
+
res.writeHead(302, {
|
76
|
+
|
77
|
+
'Location': 'https://www.myapp.com/' <-リダイレクト処理
|
78
|
+
|
79
|
+
});
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
-------------------------ここから下は関係ないです------------------------------------------
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
let q = url.parse(req.url, true);
|
88
|
+
|
89
|
+
if(req.method == "POST"){
|
90
|
+
|
91
|
+
let data = '';
|
92
|
+
|
93
|
+
req.on('data', function(chunk) {
|
94
|
+
|
95
|
+
data += chunk
|
96
|
+
|
97
|
+
});
|
98
|
+
|
99
|
+
req.on('end', function() {
|
100
|
+
|
101
|
+
let p = /[=_]/ ;
|
102
|
+
|
103
|
+
let result = data.split(p);
|
104
|
+
|
105
|
+
let result1 = result[0] ;
|
106
|
+
|
107
|
+
let result2 = result[1] ;
|
108
|
+
|
109
|
+
let item = decodeURI(result2);
|
110
|
+
|
111
|
+
console.log(item)
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
if(result1 == "thema"){
|
116
|
+
|
117
|
+
console.log("post通信でもらったitemは"+item) ;
|
118
|
+
|
119
|
+
let board_page = ejs.render(board, {
|
120
|
+
|
121
|
+
thema:item,
|
122
|
+
|
123
|
+
});
|
124
|
+
|
125
|
+
res.end(board_page);
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
}else{
|
130
|
+
|
131
|
+
console.log("post通信でもらったitemは"+item) ;
|
132
|
+
|
133
|
+
let other_page = ejs.render(other, {
|
134
|
+
|
135
|
+
username:item,
|
136
|
+
|
137
|
+
});
|
138
|
+
|
139
|
+
res.end(other_page);
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
});
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
switch (q.pathname) {
|
148
|
+
|
149
|
+
case "/":
|
150
|
+
|
151
|
+
fs.readFile("./view/index.html", "UTF-8", function(err, data) {
|
152
|
+
|
153
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
154
|
+
|
155
|
+
res.end(data);
|
156
|
+
|
157
|
+
});
|
158
|
+
|
159
|
+
break;
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
case "/login":
|
164
|
+
|
165
|
+
fs.readFile("./view/login.html", "UTF-8", function(err, data) {
|
166
|
+
|
167
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
168
|
+
|
169
|
+
res.end(data);
|
170
|
+
|
171
|
+
});
|
172
|
+
|
173
|
+
break;
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
case "/regist":
|
178
|
+
|
179
|
+
fs.readFile("./view/regist.html", "UTF-8", function(err, data) {
|
180
|
+
|
181
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
182
|
+
|
183
|
+
res.end(data);
|
184
|
+
|
185
|
+
});
|
186
|
+
|
187
|
+
break;
|
188
|
+
|
189
|
+
続く...
|
190
|
+
|
191
|
+
})
|
192
|
+
|
193
|
+
```
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
のように変更しましたが,リダイレクトは行われていませんでした
|