-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
38 lines (34 loc) · 870 Bytes
/
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
package main
import (
"io"
"log"
"net/http"
"os"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { io.WriteString(w, "Hello from a HandleFunc #1!\n") })
http.HandleFunc("/img", func(w http.ResponseWriter, _ *http.Request) {
file, err := os.Open("../阿里云盘/download/2.mp4")
if err != nil {
log.Println("打开失败" + err.Error())
}
defer file.Close()
io.Copy(w, file)
})
http.HandleFunc("/i", func(w http.ResponseWriter, _ *http.Request) {
file, err := os.Open("1.mp4")
if err != nil {
log.Println("打开失败" + err.Error())
}
defer file.Close()
io.Copy(w, file)
})
err := http.ListenAndServe(":80", nil)
if err != nil {
log.Println(err)
}
//err := http.ListenAndServeTLS(":8082", "../ssl/xlei.love.pem", "../ssl/xlei.love.key", nil)
//if err != nil {
// log.Println(err)
//}
}