package main

import (
	"fmt"
	"net/http"
	"log"
	"html/template"
)

func main ()  {
	//实例化一个 HTTP
	app := http.NewServeMux();
	app.HandleFunc("/",func(w http.ResponseWriter,r *http.Request){
		switch r.Method {
		case "GET":
			tmpl,_ := template.ParseFiles("./View/home.html");
			tmpl.Execute(w,"Master");
		case "POST":
		case "PUT":
		case "DELETE":
		default:
		}
	});
	address := "127.0.0.1:80"
	fmt.Printf("Application: running using host(http://%s) \n",address);
	log.Fatal(http.ListenAndServe(address,app));
}

View/home.html

<html>
    <head>
        <title>Hello World!</title>
    </head>
    <body>
        <center>
            <h1>Hello,My name is {{.}}</h1>
        </center>
    </body>
</html>

相关文章:

  • 2021-12-04
  • 2022-12-23
  • 1970-01-01
  • 2021-12-22
  • 2021-11-17
  • 2021-11-19
  • 2022-02-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2023-03-06
  • 1970-01-01
  • 2021-08-13
  • 2021-07-24
  • 2022-12-23
相关资源
相似解决方案