Static serve

This commit is contained in:
Eden Kirin
2023-10-26 22:08:14 +02:00
parent 3290837555
commit 442b145711
5 changed files with 28 additions and 14 deletions

View File

@ -19,6 +19,7 @@ type configStruct struct {
DisableSendMail bool `yaml:"disableSendMail"` DisableSendMail bool `yaml:"disableSendMail"`
IsProduction bool `yaml:"isProduction"` IsProduction bool `yaml:"isProduction"`
LoopDelay uint32 `yaml:"loopDelay"` LoopDelay uint32 `yaml:"loopDelay"`
StaticDir string `yaml:"staticDir"`
} `yaml:"application"` } `yaml:"application"`
Database struct { Database struct {
Host string `yaml:"host"` Host string `yaml:"host"`

View File

@ -91,6 +91,11 @@ func createApp() *iris.Application {
app.UseRouter(accessLog.Handler) app.UseRouter(accessLog.Handler)
app.RegisterView(iris.Jet("./app/templates", ".jet").Reload(true)) app.RegisterView(iris.Jet("./app/templates", ".jet").Reload(true))
views.CreateRouter(app) views.CreateRouter(app)
if len(cfg.Config.Application.StaticDir) > 0 {
app.HandleDir("/static", iris.Dir(cfg.Config.Application.StaticDir))
}
return app return app
} }

View File

@ -4,8 +4,9 @@
{{ block mainContent() }} {{ block mainContent() }}
<div class="row"> <div class="row mt-5">
<form class="mb-5 col-4 ms-auto me-auto" method="post" action="/"> <div class="col">
<form method="post" action="/">
<div class="mb-3"> <div class="mb-3">
<label class="form-label">Email address</label> <label class="form-label">Email address</label>
<input type="email" name="email" class="form-control" value="edkirin@gmail.com"> <input type="email" name="email" class="form-control" value="edkirin@gmail.com">
@ -19,7 +20,13 @@
Submit Submit
</button> </button>
</form> </form>
</div> </div>
<div class="col">
<img src="/static/sample.jpg" class="img-fluid" alt="">
</div>
</div>
<div class="lead"> <div class="lead">
<p>Bacon ipsum dolor amet leberkas kevin meatball pork loin beef ribs prosciutto, turducken bacon bresaola tri-tip. <p>Bacon ipsum dolor amet leberkas kevin meatball pork loin beef ribs prosciutto, turducken bacon bresaola tri-tip.

View File

@ -5,6 +5,7 @@ application:
debugSQL: true debugSQL: true
isProduction: false isProduction: false
loopDelay: 3000 loopDelay: 3000
staticDir: "./static"
database: database:
host: "localhost" host: "localhost"

BIN
static/sample.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB