2017-06-15 19:02:08 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-10-25 00:27:02 +02:00
|
|
|
"github.com/kataras/iris/v12"
|
2017-06-15 19:02:08 +02:00
|
|
|
)
|
|
|
|
|
2020-09-05 07:56:01 +02:00
|
|
|
// $ go get -u github.com/go-bindata/go-bindata/...
|
2020-09-05 07:34:09 +02:00
|
|
|
// # OR: go get -u github.com/go-bindata/go-bindata/v3/go-bindata
|
|
|
|
// # to save it to your go.mod file
|
|
|
|
// $ go-bindata -fs -prefix "public" ./public/...
|
2019-10-25 00:04:08 +02:00
|
|
|
// $ go run .
|
2017-06-15 19:02:08 +02:00
|
|
|
|
|
|
|
var page = struct {
|
|
|
|
Title string
|
|
|
|
}{"Welcome"}
|
|
|
|
|
|
|
|
func newApp() *iris.Application {
|
|
|
|
app := iris.New()
|
2020-09-05 07:34:09 +02:00
|
|
|
|
|
|
|
app.RegisterView(iris.HTML(AssetFile(), ".html"))
|
|
|
|
|
|
|
|
app.HandleDir("/", AssetFile())
|
2017-06-15 19:02:08 +02:00
|
|
|
|
2017-08-27 19:35:23 +02:00
|
|
|
app.Get("/", func(ctx iris.Context) {
|
2017-06-15 19:02:08 +02:00
|
|
|
ctx.ViewData("Page", page)
|
|
|
|
ctx.View("index.html")
|
|
|
|
})
|
|
|
|
|
|
|
|
return app
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := newApp()
|
|
|
|
|
|
|
|
// http://localhost:8080
|
|
|
|
// http://localhost:8080/app.js
|
|
|
|
// http://localhost:8080/css/main.css
|
2019-10-25 00:04:08 +02:00
|
|
|
// http://localhost:8080/app2
|
2020-03-05 21:41:27 +01:00
|
|
|
app.Listen(":8080")
|
2017-06-15 19:02:08 +02:00
|
|
|
}
|