Minor changes

This commit is contained in:
2016-10-21 22:10:05 +09:00
parent 8d4cc6439a
commit c8a3ec4b04
7 changed files with 37 additions and 7 deletions

View File

@ -4,26 +4,36 @@ import (
"fmt"
"time"
web "github.com/kataras/iris"
"github.com/kataras/go-template/pug"
"github.com/kataras/iris"
)
func main() {
InitDatabase()
web.Get("/", func(ctx *web.Context) {
iris.Config.Gzip = true
iris.Config.IsDevelopment = true
cfg := pug.DefaultConfig()
cfg.Layout = "layout.pug"
iris.UseTemplate(pug.New(cfg)).Directory("pages", ".pug")
iris.Static("/styles", "./styles", 1)
iris.Get("/", func(ctx *iris.Context) {
ctx.Response.Header.Set("Content-Type", "text/html;charset=utf-8")
ctx.Write(ctx.Request.URI().String())
})
web.Get("/anime/:id", func(ctx *web.Context) {
iris.Get("/anime/:id", func(ctx *iris.Context) {
start := time.Now()
id, _ := ctx.ParamInt("id")
anime := GetAnime(id)
ctx.Write(anime.Title.Romaji + "\n")
ctx.Write(anime.Description)
ctx.MustRender("anime.pug", anime)
fmt.Println(time.Since(start))
})
web.Listen(":8082")
iris.Listen(":8082")
}