1 Star 0 Fork 0

hh/iris

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 975 Bytes
一键复制 编辑 原始数据 按行查看 历史
package main
import (
"github.com/kataras/iris"
)
// 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")
})
// or just serve index.html as it is:
// app.Get("/", func(ctx iris.Context) {
// ctx.ServeFile("index.html", false)
// })
assetHandler := app.StaticHandler("./public", false, false)
// as an alternative of SPA you can take a look at the /routing/dynamic-path/root-wildcard
// example too
app.SPA(assetHandler)
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"))
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/w1229748769/iris.git
git@gitee.com:w1229748769/iris.git
w1229748769
iris
iris
v8.4.2

搜索帮助