mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 18:51:03 +01:00
0d26f24eb7
Former-commit-id: d20afb2e899aee658a8e0ed1693357798df93462
32 lines
747 B
Go
32 lines
747 B
Go
package main
|
|
|
|
import (
|
|
"github.com/kataras/iris/v12"
|
|
)
|
|
|
|
func main() {
|
|
app := iris.New()
|
|
|
|
app.RegisterView(iris.HTML("./views", ".html").Layout("layout.html"))
|
|
// TIP: append .Reload(true) to reload the templates on each request.
|
|
|
|
app.Get("/home", func(ctx iris.Context) {
|
|
ctx.ViewData("title", "Home page")
|
|
ctx.View("home.html")
|
|
// Note that: you can pass "layout" : "otherLayout.html" to bypass the config's Layout property
|
|
// or view.NoLayout to disable layout on this render action.
|
|
// third is an optional parameter
|
|
})
|
|
|
|
app.Get("/about", func(ctx iris.Context) {
|
|
ctx.View("about.html")
|
|
})
|
|
|
|
app.Get("/user/index", func(ctx iris.Context) {
|
|
ctx.View("user/index.html")
|
|
})
|
|
|
|
// http://localhost:8080
|
|
app.Listen(":8080")
|
|
}
|