mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 18:51:03 +01:00
0d26f24eb7
Former-commit-id: d20afb2e899aee658a8e0ed1693357798df93462
42 lines
754 B
Go
42 lines
754 B
Go
package main
|
|
|
|
import (
|
|
"github.com/kataras/iris/v12"
|
|
)
|
|
|
|
// $ go get -u github.com/go-bindata/go-bindata/...
|
|
// $ go-bindata ./public/...
|
|
// $ go run .
|
|
|
|
var page = struct {
|
|
Title string
|
|
}{"Welcome"}
|
|
|
|
func newApp() *iris.Application {
|
|
app := iris.New()
|
|
app.RegisterView(iris.HTML("./public", ".html").Binary(Asset, AssetNames))
|
|
|
|
app.Get("/", func(ctx iris.Context) {
|
|
ctx.ViewData("Page", page)
|
|
ctx.View("index.html")
|
|
})
|
|
|
|
app.HandleDir("/", "./public", iris.DirOptions{
|
|
Asset: Asset,
|
|
AssetInfo: AssetInfo,
|
|
AssetNames: AssetNames,
|
|
})
|
|
|
|
return app
|
|
}
|
|
|
|
func main() {
|
|
app := newApp()
|
|
|
|
// http://localhost:8080
|
|
// http://localhost:8080/app.js
|
|
// http://localhost:8080/css/main.css
|
|
// http://localhost:8080/app2
|
|
app.Listen(":8080")
|
|
}
|