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
|
|
|
)
|
|
|
|
|
2019-12-29 18:14:41 +01:00
|
|
|
// $ go get -u github.com/go-bindata/go-bindata/...
|
2017-06-15 19:02:08 +02:00
|
|
|
// $ go-bindata ./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()
|
2017-08-27 19:35:23 +02:00
|
|
|
app.RegisterView(iris.HTML("./public", ".html").Binary(Asset, AssetNames))
|
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")
|
|
|
|
})
|
|
|
|
|
2019-06-21 18:43:25 +02:00
|
|
|
app.HandleDir("/", "./public", iris.DirOptions{
|
|
|
|
Asset: Asset,
|
|
|
|
AssetInfo: AssetInfo,
|
|
|
|
AssetNames: AssetNames,
|
|
|
|
})
|
2017-06-15 19:02:08 +02:00
|
|
|
|
|
|
|
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
|
|
|
}
|