mirror of
https://github.com/kataras/iris.git
synced 2025-01-24 03:01:03 +01:00
d0104defa8
relative: https://github.com/kataras/iris/issues/1283 and removing pongo2 from vendor: https://github.com/kataras/iris/issues/1284 Former-commit-id: 3ec57b349f99faca2b8e36d9f7252db0b6ea080d
43 lines
801 B
Go
43 lines
801 B
Go
package main
|
|
|
|
import (
|
|
"github.com/kataras/iris"
|
|
)
|
|
|
|
// $ go get -u github.com/shuLhan/go-bindata/...
|
|
// $ go-bindata ./public/...
|
|
// $ go build
|
|
// $ ./embedded-single-page-application
|
|
|
|
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/index.html
|
|
// http://localhost:8080/app.js
|
|
// http://localhost:8080/css/main.css
|
|
app.Run(iris.Addr(":8080"))
|
|
}
|