-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
150 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/kotlin/com/example/demoserver/controller/PeperoController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.example.demoserver.controller | ||
|
||
import org.springframework.stereotype.Controller | ||
import org.springframework.stereotype.Service | ||
import org.springframework.ui.Model | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
|
||
|
||
@Controller | ||
@RequestMapping("/pepero") | ||
class PeperoController( | ||
private val peperoService: PeperoService | ||
) { | ||
|
||
@GetMapping | ||
fun pepero(): String { | ||
return "pepero" | ||
} | ||
|
||
@PostMapping("/result") | ||
fun getRandomOne(model: Model) : String { | ||
model.addAttribute("result", peperoService.getRandomOne()) | ||
return "pepero_result" | ||
} | ||
|
||
@GetMapping("/result") | ||
fun peperoResult(): String{ | ||
return "pepero_result" | ||
} | ||
|
||
} | ||
|
||
@Service | ||
class PeperoService() { | ||
fun getRandomOne() : String { | ||
return serverPart.get((0..serverPart.size).random()) | ||
} | ||
|
||
companion object { | ||
private val serverPart: List<String> = listOf("김성은","소예원","임주민","김수현","이동섭","도소현","정홍준","안현주","최승준","박예준","정준서","최승빈","최영린","황선웅","김태욱","김다현","현예진","윤정원","이혜연","석미혜","김승환","이승연","현예진","신민철","남궁찬","이나경","송민규","박재연","김보람","박상준","박지영","박희정","박경린","송하연") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" | ||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>빼빼로데이 기념 빼빼로 뽑기</title> | ||
|
||
<style> | ||
body { | ||
margin: 10vh; | ||
height: 60vh; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
flex-direction: column; | ||
} | ||
h1 { | ||
margin-bottom: 20px; | ||
} | ||
img { | ||
width: 1000px; | ||
height: 600px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<img src="/image/server.png" /> | ||
|
||
<form action="/pepero/result" method="POST"> | ||
<button> 뽑기</button> | ||
|
||
</form> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" | ||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
|
||
<style> | ||
body { | ||
margin: 10vh; | ||
height: 60vh; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
flex-direction: column; | ||
} | ||
h1 { | ||
margin-bottom: 20px; | ||
} | ||
img { | ||
width: 300px; | ||
height: 300px; | ||
} | ||
#countdown { | ||
font-size: 200px; | ||
} | ||
</style> | ||
|
||
<script> | ||
function startCountdown() { | ||
var counter = 3; | ||
var interval = setInterval(function() { | ||
document.getElementById('countdown').innerHTML = counter; | ||
counter--; | ||
if (counter < 0 ) { | ||
clearInterval(interval); | ||
document.getElementById('countdown').innerHTML = '{{ result }}' | ||
} | ||
}, 1000); | ||
} | ||
</script> | ||
</head> | ||
|
||
<body onload="startCountdown()"> | ||
<div id="countdown"></div> | ||
<form action="/pepero" method="GET" style="margin: 100px 0 0 0"> | ||
<button type="submit"> 돌아가기 </button> | ||
</form> | ||
</body> | ||
</html> |