[Go] gocron -go read the source language web framework Macaron

gocron source is used macarons framework, the following is the installation of this framework, and general MVC framework like
Go GET gopkg.in/macaron.v1
git clone https://github.com/golang/crypto.git $ GOPATH / src / golang.org / x / crypto

A simple example listening on port 80, using a template engine

package main

import "gopkg.in/macaron.v1"

func main() {
    m := macaron.Classic()
    //使用模板引擎
    m.Use(macaron.Renderer())
    m.Get("/", func(ctx *macaron.Context) {
        ctx.Data["Name"] = "taoshihan"
        ctx.HTML(200, "index") // 200 为响应码
    })
    m.Run("0.0.0.0", 80)
}

Create templates in the current directory /, xxx.tmpl, you call the template name and the name of the corresponding

index.tmpl

<h2>{{.Name}}</h2>

 

Guess you like

Origin www.cnblogs.com/taoshihan/p/11872721.html