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
|
|
|
)
|
|
|
|
|
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")
|
|
|
|
})
|
|
|
|
|
2020-07-24 12:03:49 +02:00
|
|
|
app.HandleDir("/", iris.Dir("./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
|
2020-03-05 21:41:27 +01:00
|
|
|
app.Listen(":8080")
|
2017-06-15 19:02:08 +02:00
|
|
|
}
|