공태현

Implement move page function and get-js-file-API

...@@ -15,6 +15,12 @@ app.get('/', (req,res) => { ...@@ -15,6 +15,12 @@ app.get('/', (req,res) => {
15 res.render('main.html') 15 res.render('main.html')
16 }) 16 })
17 17
18 +
19 +// js 파일 전송.
20 +app.get('/main.js', (req,res) => {
21 + res.sendFile( __dirname + '/views/mainPage/main.js')
22 +})
23 +
18 app.get('/squart', (req,res) => { 24 app.get('/squart', (req,res) => {
19 app.set('views', __dirname + '/views/squartPage') 25 app.set('views', __dirname + '/views/squartPage')
20 res.render('squart.html') 26 res.render('squart.html')
......
...@@ -8,5 +8,10 @@ ...@@ -8,5 +8,10 @@
8 </head> 8 </head>
9 <body> 9 <body>
10 Main Page 10 Main Page
11 + <div>
12 + <input type="button" value = "squart start" id = "moveSquart" onclick="moveSquartPage()"/>
13 + </div>
14 +
15 + <script type="text/javascript" src="./main.js"></script>
11 </body> 16 </body>
12 </html> 17 </html>
...\ No newline at end of file ...\ No newline at end of file
......
1 +
2 +
3 +function moveSquartPage()
4 +{
5 + location.href = "/squart";
6 +}
7 +
8 +const movePage = document.getElementById("moveSquart")
9 +
10 +movePage.addEventListener('click', moveSquartPage);
...\ No newline at end of file ...\ No newline at end of file