-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathmain.go
More file actions
52 lines (46 loc) · 1.21 KB
/
main.go
File metadata and controls
52 lines (46 loc) · 1.21 KB
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
51
52
package main
import (
"fmt"
"github.com/AccentDesign/gcss/examples/full/styles"
"net/http"
)
var (
stylesheet = styles.NewStyleSheet()
html = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1" name="viewport" />
<meta content="Example starting point written in gcss." name="description" />
<title>Theme</title>
<link rel="stylesheet" href="/stylesheet.css">
</head>
<body>
<main>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<div>
<button class="button button-primary">Click me</button>
</div>
</main>
</body>
</html>
`
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if _, err := fmt.Fprint(w, html); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
})
http.HandleFunc("/stylesheet.css", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/css")
if err := stylesheet.CSS(w); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
})
fmt.Println("Server started at http://localhost:8080")
if err := http.ListenAndServe(":8080", nil); err != nil {
panic(err)
}
}