File tree Expand file tree Collapse file tree 4 files changed +127
-0
lines changed Expand file tree Collapse file tree 4 files changed +127
-0
lines changed Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "fmt"
5+ "os"
6+ )
7+
8+ func main () {
9+ fmt .Println ("Are you human?" )
10+ fmt .Println ("YES or NO" )
11+ var answer string
12+ _ , err := fmt .Scanf ("%s" , & answer )
13+ if err != nil {
14+ panic (err )
15+ }
16+ if answer != "YES" {
17+ fmt .Println ("You're not human! What?!?!" )
18+ os .Exit (0 )
19+ }
20+ fmt .Println ("I am glad you are human" )
21+ }
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "net/http"
5+ "fmt"
6+ )
7+
8+ func main () {
9+ http .HandleFunc ("/" , foo )
10+ http .ListenAndServe (":8080" , nil )
11+ }
12+
13+ func foo (w http.ResponseWriter , r * http.Request ) {
14+ fmt .Fprint (w , "Hello from foo" )
15+ }
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "net/http"
5+ "fmt"
6+ )
7+
8+ func main () {
9+ http .HandleFunc ("/" , index )
10+ http .HandleFunc ("/about" , about )
11+ http .HandleFunc ("/contact" , contact )
12+ http .ListenAndServe (":8080" , nil )
13+ }
14+
15+ func index (w http.ResponseWriter , r * http.Request ) {
16+ fmt .Fprint (w , `<!DOCTYPE html>
17+ <html lang="en">
18+ <head>
19+ <meta charset="UTF-8">
20+ <title>index</title>
21+ <style>
22+ html {
23+ font-size: 48px;
24+ }
25+ </style>
26+ </head>
27+ <body>
28+ Hello from index
29+ <br><br>
30+ <a href="/">index</a>
31+ <a href="/about">about</a>
32+ <a href="/contact">contact</a>
33+ </body>
34+ </html>` )
35+ }
36+
37+
38+ func about (w http.ResponseWriter , r * http.Request ) {
39+ fmt .Fprint (w , `<!DOCTYPE html>
40+ <html lang="en">
41+ <head>
42+ <meta charset="UTF-8">
43+ <title>about</title>
44+ <style>
45+ html {
46+ font-size: 48px;
47+ }
48+ </style>
49+ </head>
50+ <body>
51+ Hello from about
52+ <br><br>
53+ <a href="/">index</a>
54+ <a href="/about">about</a>
55+ <a href="/contact">contact</a>
56+ </body>
57+ </html>` )
58+ }
59+
60+
61+ func contact (w http.ResponseWriter , r * http.Request ) {
62+ fmt .Fprint (w , `<!DOCTYPE html>
63+ <html lang="en">
64+ <head>
65+ <meta charset="UTF-8">
66+ <title>contact</title>
67+ <style>
68+ html {
69+ font-size: 48px;
70+ }
71+ </style>
72+ </head>
73+ <body>
74+ Hello from contact
75+ <br><br>
76+ <a href="/">index</a>
77+ <a href="/about">about</a>
78+ <a href="/contact">contact</a>
79+ </body>
80+ </html>` )
81+ }
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > Title</ title >
6+ </ head >
7+ < body >
8+
9+ </ body >
10+ </ html >
You can’t perform that action at this time.
0 commit comments