-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (39 loc) · 1.66 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"fmt"
"net/http"
"github.com/go-chi/chi/v5"
)
func homeHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprint(w, "<h1>Welcome to Arcade!</p>")
}
func contactHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprint(w, "<h1>Contact Page</h1><p>To get in touch, email me at <a href=\"mailto:[email protected]\">[email protected]</a></p>.")
}
func faqHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprint(w, `<h1>Arcade - FAQ Page<h1>
<h2>General Questions</h2>
<ul>
<li><b>Q: What is Arcade?</b></li>
<li>A: Arcade is a web application designed to provide users with a curated selection of artworks, photographs, and images from various artists and photographers around the world, offering an immersive visual experience.</li>
<li><b>Q: How do I navigate through Arcade?</b></li>
<li>A: Arcade offers intuitive navigation features, allowing users to browse through different collections, search for specific artworks, and discover new favorites easily.</li>
<li><b>Q: Is Arcade free to use?</b></li>
<li>A: Yes, Arcade is completely free to use and host your images.</li>
</ul>
`)
}
func main() {
router := chi.NewRouter()
router.Get("/", homeHandler)
router.Get("/contact", contactHandler)
router.Get("/faq", faqHandler)
router.NotFound(func(w http.ResponseWriter, r *http.Request){
http.Error(w, "Page not found", http.StatusNotFound)
})
fmt.Println("Server is running at PORT 8000...")
http.ListenAndServe(":8000", router)
}