Minor changes
This commit is contained in:
22
src/main.go
22
src/main.go
@ -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")
|
||||
}
|
||||
|
Reference in New Issue
Block a user