Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ede84bec24 | ||
|
|
6e98443bb9 |
@@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>GDG Talk Counter</title>
|
||||
<link rel="stylesheet" href="/src/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>GDG Counter Website</h1>
|
||||
|
||||
@@ -21,6 +21,10 @@ func main() {
|
||||
}
|
||||
|
||||
func setupRoutes(mux *http.ServeMux) {
|
||||
counter := 0
|
||||
|
||||
// API Routes
|
||||
|
||||
mux.HandleFunc("/api/status", func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet {
|
||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||
@@ -36,6 +40,52 @@ func setupRoutes(mux *http.ServeMux) {
|
||||
}
|
||||
})
|
||||
|
||||
mux.HandleFunc("/api/value", func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet {
|
||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
err := json.NewEncoder(w).Encode(counter)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
mux.HandleFunc("/api/increment", func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
counter++
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
err := json.NewEncoder(w).Encode(counter)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
mux.HandleFunc("/api/decrement", func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
counter--
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
err := json.NewEncoder(w).Encode(counter)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
// Static Files
|
||||
mux.Handle("/", http.FileServer(http.Dir("./dist/")))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
font-family: inherit;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-align: center;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.app {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
#counter-value {
|
||||
grid-column: span 2;
|
||||
|
||||
place-self: center;
|
||||
|
||||
font-weight: 200;
|
||||
font-size: 32px;
|
||||
|
||||
padding: 1rem 0;
|
||||
}
|
||||
|
||||
button {
|
||||
/* box-shadow: 0 0 4px 0 #00000018, 0 0 32px 0 #00000010; */
|
||||
|
||||
border: 1px solid #d4d4d4;
|
||||
background: linear-gradient(to bottom, #f8f8f8 0%, #f0f0f0 50%, #d8d8d8 100%);
|
||||
|
||||
color: #333;
|
||||
|
||||
font-size: 15px;
|
||||
font-weight: 400;
|
||||
|
||||
border-radius: 0.5rem;
|
||||
height: 2rem;
|
||||
padding: 0 1rem;
|
||||
|
||||
cursor: pointer;
|
||||
|
||||
transition: all 250ms ease-in-out;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
/* box-shadow: 0 0 4px 0 #00000018, 0 0 24px 4px #00000018; */
|
||||
|
||||
border: 1px solid #d0d0d0;
|
||||
background: linear-gradient(to bottom, #fdfdfd 0%, #ededed 40%, #ededed 60%, #d0d0d0 100%);
|
||||
}
|
||||
|
||||
button:active {
|
||||
/* box-shadow: 0 0 4px 0 #00000018, 0 0 24px 4px #00000018; */
|
||||
|
||||
border: 1px solid #c8c8c8;
|
||||
background: linear-gradient(to bottom, #fdfdfd 0%, #e4e4e4 50%, #c8c8c8 100%);
|
||||
}
|
||||
@@ -3,5 +3,8 @@ import { defineConfig } from 'vite'
|
||||
export default defineConfig({
|
||||
server: {
|
||||
port: 3000,
|
||||
proxy: {
|
||||
'/api': 'http://localhost:4000/',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user