2017-06-15 19:02:08 +02:00
|
|
|
package main
|
|
|
|
|
2020-09-14 17:36:04 +02:00
|
|
|
import "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-14 17:36:04 +02:00
|
|
|
// $ go-bindata -fs ./data/...
|
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
|
|
|
|
2020-09-14 17:36:04 +02:00
|
|
|
// Using the iris.PrefixDir you can select
|
|
|
|
// which directories to use under a particular file system,
|
|
|
|
// e.g. for views the ./data/views and for static files
|
|
|
|
// the ./data/public.
|
|
|
|
templatesFS := iris.PrefixDir("./data/views", AssetFile())
|
|
|
|
app.RegisterView(iris.HTML(templatesFS, ".html"))
|
2020-09-05 07:34:09 +02:00
|
|
|
|
2020-09-14 17:36:04 +02:00
|
|
|
publicFS := iris.PrefixDir("./data/public", AssetFile())
|
|
|
|
app.HandleDir("/", publicFS)
|
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
|
|
|
}
|