Skip to content

Commit cfff11b

Browse files
committed
new file: ../../c/fileio/src/file.txt
new file: main.go new file: test.bat new file: test.go
1 parent 378c0fb commit cfff11b

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

c/fileio/src/file.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
this is an apple

go/web/main.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"net/http"
7+
)
8+
9+
var indexhtml = `
10+
<!DOCTYPE html>
11+
<html>
12+
<head>
13+
<meta http-equiv="Content-type" content="test/html" ; charset="utf-8">
14+
<title> This is Mayuri </title>
15+
</head>
16+
<body>
17+
<h2>Title </h2>
18+
<p>Paragraph<p>
19+
</body>
20+
</html>
21+
`
22+
23+
func index(w http.ResponseWriter, r *http.Request) {
24+
fmt.Fprintf(w, indexhtml)
25+
}
26+
func main() {
27+
http.HandleFunc("/test", index)
28+
err := http.ListenAndServe(":3344", nil)
29+
if err != nil {
30+
log.Fatal("ListenAndServe", err)
31+
}
32+
}

go/web/test.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
go build main.go && main.exe

go/web/test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"net/http"
7+
)
8+
9+
//go doc Server
10+
func index(w http.ResponseWriter, r *http.Request) {
11+
fmt.Fprintf(w, "Hello world!")
12+
//fmt.Fprintf(w io.Writer,format string,a ...interface{})(n int, err error)
13+
//io.WriteString(w io.Writer,String string)
14+
}
15+
func main() {
16+
http.HandleFunc("/", index)
17+
//http.HandleFunc(pattern string,handler func(w http.ResponseWriter,w *http.Request)
18+
err := http.ListenAndServe(":9090", nil)
19+
//http.ListenAndServe(addr string, handler Handler)
20+
if err != nil {
21+
log.Fatal("ListenAndServe:", err)
22+
}
23+
}

0 commit comments

Comments
 (0)