mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 18:51:03 +01:00
c3205dafa1
Read HISTORY.md it contains a breaking change, second parameter of HandleDir should be iris.Dir(...) instead of just a string relative to: https://github.com/kataras/iris/issues/1556#issuecomment-661057446 Former-commit-id: 14b48a06fb3b99287dff543932be2937a64233b9
37 lines
692 B
Go
37 lines
692 B
Go
package main
|
|
|
|
import (
|
|
"github.com/kataras/iris/v12"
|
|
)
|
|
|
|
// same as embedded-single-page-application but without go-bindata, the files are "physical" stored in the
|
|
// current system directory.
|
|
|
|
var page = struct {
|
|
Title string
|
|
}{"Welcome"}
|
|
|
|
func newApp() *iris.Application {
|
|
app := iris.New()
|
|
app.RegisterView(iris.HTML("./public", ".html"))
|
|
|
|
app.Get("/", func(ctx iris.Context) {
|
|
ctx.ViewData("Page", page)
|
|
ctx.View("index.html")
|
|
})
|
|
|
|
app.HandleDir("/", iris.Dir("./public"))
|
|
|
|
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.Listen(":8080")
|
|
}
|