2017-06-15 19:02:08 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/kataras/iris"
|
|
|
|
)
|
|
|
|
|
2017-07-10 17:32:42 +02:00
|
|
|
// same as embedded-single-page-application but without go-bindata, the files are "physical" stored in the
|
2017-06-15 19:02:08 +02:00
|
|
|
// current system directory.
|
|
|
|
|
|
|
|
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"))
|
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")
|
2017-06-15 19:02:08 +02:00
|
|
|
|
|
|
|
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"))
|
|
|
|
}
|