質問編集履歴
2
コードの追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -83,10 +83,36 @@
|
|
83
83
|
app.use(bodyParser.urlencoded({ extended: true }));
|
84
84
|
app.use(bodyParser.json());
|
85
85
|
|
86
|
+
// mySQLの認証情報
|
87
|
+
// ここには正しい値が入っています
|
88
|
+
const mysql = require('mysql');
|
89
|
+
const connection = mysql.createConnection({
|
90
|
+
host: 'localhost',
|
91
|
+
user: 'root',
|
92
|
+
password: 'password',
|
93
|
+
database: 'table'
|
94
|
+
});
|
95
|
+
|
86
96
|
// テンプレートエンジンの定義
|
87
97
|
app.set('view engine', 'pug');
|
88
98
|
app.use(express.static('views'));
|
89
99
|
|
100
|
+
// モジュール化されたルーティング設定の呼び出し
|
101
|
+
const index = require('./routes/admin_server');
|
102
|
+
|
103
|
+
// インデックスページのルーティング
|
104
|
+
app.use('/', index);
|
105
|
+
app.use('/admin_login', index);
|
106
|
+
app.use('/admin_menu', index);
|
107
|
+
app.use('/device_list', index);
|
108
|
+
app.use('/patient_list', index);
|
109
|
+
app.use('/device_register', index);
|
110
|
+
app.use('/patient_register', index);
|
111
|
+
|
112
|
+
// テンプレートエンジンの定義
|
113
|
+
app.set('view engine', 'pug');
|
114
|
+
app.use(express.static('views'));
|
115
|
+
|
90
116
|
app.get('/device_list', isAuthenticated, function (req, res) {
|
91
117
|
var sql = 'select * from facility.devices';
|
92
118
|
fullUrl = req.protocol + '://' + req.get('Host') + req.originalUrl;
|
@@ -105,6 +131,36 @@
|
|
105
131
|
|
106
132
|
```
|
107
133
|
|
134
|
+
```./routes/admin_server.js
|
135
|
+
const express = require('express');
|
136
|
+
const router = express.Router();
|
137
|
+
|
138
|
+
// インデックスページのルーティング
|
139
|
+
router.get('/', (req, res) =>{
|
140
|
+
res.render('admin_server');
|
141
|
+
});
|
142
|
+
router.get('/admin_login', (req, res) =>{
|
143
|
+
res.render('admin_login');
|
144
|
+
});
|
145
|
+
router.get('/admin_menu', (req, res) => {
|
146
|
+
res.render('admin_menu');
|
147
|
+
})
|
148
|
+
router.get('/device_list', (req, res) =>{
|
149
|
+
res.render('device_list');
|
150
|
+
});
|
151
|
+
router.get('/patient_list', (req, res) => {
|
152
|
+
res.render('patient_list');
|
153
|
+
})
|
154
|
+
router.get('/device_register', (req, res) => {
|
155
|
+
res.render('device_register');
|
156
|
+
})
|
157
|
+
router.get('/patient_register', (req, res) => {
|
158
|
+
res.render('patient_register');
|
159
|
+
})
|
160
|
+
|
161
|
+
module.exports = router;
|
162
|
+
```
|
163
|
+
|
108
164
|
### 試したこと
|
109
165
|
|
110
166
|
インデントの入れ替えや変数の書き換え、ルーティングのリンクの書き換えなども試しましたが効果なしでした。
|
1
エラー追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -109,6 +109,51 @@
|
|
109
109
|
|
110
110
|
インデントの入れ替えや変数の書き換え、ルーティングのリンクの書き換えなども試しましたが効果なしでした。
|
111
111
|
|
112
|
+
res.render(/device_list)の直前でconsole.log(rows)を実行しましたが、そもそもここに至らず、同じエラーが吐かれてしまいました
|
113
|
+
|
114
|
+
当該のeach文のところをコメントアウトし実行したところ、ページが正しく遷移しました
|
115
|
+
```pug
|
116
|
+
html
|
117
|
+
head
|
118
|
+
title #{title}
|
119
|
+
link(rel="stylesheet" href="/css/style.css")
|
120
|
+
body
|
121
|
+
h1 Device List
|
122
|
+
table.facility_table
|
123
|
+
tr.title
|
124
|
+
td Device ID
|
125
|
+
td Set Place Name
|
126
|
+
td Set Place Address
|
127
|
+
td Place Manager Name
|
128
|
+
td Place Manager Address
|
129
|
+
td Manager's Tell Number
|
130
|
+
td Manager's Mail Address
|
131
|
+
td Place Longitude Latitude
|
132
|
+
td Edit or DEL
|
133
|
+
|
134
|
+
//- each device in d
|
135
|
+
//- tr
|
136
|
+
//- td.id #{device.id}
|
137
|
+
//- td.id #{device.set_name}
|
138
|
+
//- td.id #{device.set_address}
|
139
|
+
//- td.id #{device.manager_name}
|
140
|
+
//- td.id #{device.manager_address}
|
141
|
+
//- td.id #{device.tel}
|
142
|
+
//- td.id #{device.mail}
|
143
|
+
//- td.id #{device.e_n}
|
144
|
+
//- td.id
|
145
|
+
//- - var id = device.id
|
146
|
+
//- form(action="/device_edit" method="get")
|
147
|
+
//- input(type="hidden" name="id" value=`${id}`)
|
148
|
+
//- button(type="submit").btn.edit Edit
|
149
|
+
//- form(action="/del" method="post")
|
150
|
+
//- input(type="hidden" name="id" value=`${id}`)
|
151
|
+
//- button(type="submit").btn.del DEL
|
152
|
+
|
153
|
+
a(href="/admin_menu") トップ
|
154
|
+
```
|
155
|
+

|
156
|
+
|
112
157
|
### 補足情報(FW/ツールのバージョンなど)
|
113
158
|
|
114
159
|
[参考](https://qiita.com/KONTA2019/items/768348ee0ac5462648bd)を見ましたが、railsではないのであまりわかりませんでした。
|