2,190
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>网页标题</title>
<script>
function test() {
var a = 5
alert(a)
}
</script>
</head>
<body>
<details>
<summary>数学分析</summary>
数学分析是一门研究极限的换序的一门学科。
</details>
<br />
图像域:<br />
<input type="image" src="abc.jpg" alt="可爱妹子" /><br />
<br />
四个按钮:<br />
<input id="ok" name="ok" type="submit" value="提交" />
<input id="dis" name="dis" type="submit" value="提交" disabled="disabled" />
<input id="cancel" name="cancel" type="reset" value="重填" />
<input id="no" name="no" type="button" value="无动作" onclick="test()" />
</body>
</html>
package main
import (
"bytes"
"fmt"
"html/template"
"net/http"
)
func WriteHttpResponse(w http.ResponseWriter, rb []byte) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.Write(rb)
}
func home(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
t, _ := template.ParseFiles("home.html")
var buf bytes.Buffer
t.Execute(&buf, nil)
WriteHttpResponse(w, buf.Bytes())
}
}
func BeginServe() error {
http.HandleFunc("/", home)
err := http.ListenAndServe(":80", nil)
return err
}
func main() {
err := BeginServe()
fmt.Println(err)
}
http.Handle("/image/", http.FileServer(http.Dir("image")))
把html中图片文件改成
<input type="image" src="image/abc.jpg" alt="可爱妹子" /><br />
并且把计算机中的图片文件移到image\目录下
t, err := template.ParseFiles("home.html")
if err != nil {
panic(err)
}