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"`
IsProduction bool `yaml:"isProduction"`
LoopDelay uint32 `yaml:"loopDelay"`
StaticDir string `yaml:"staticDir"`
} `yaml:"application"`
Database struct {
Host string `yaml:"host"`

View File

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

View File

@ -4,23 +4,30 @@
{{ block mainContent() }}
<div class="row">
<form class="mb-5 col-4 ms-auto me-auto" method="post" action="/">
<div class="mb-3">
<label class="form-label">Email address</label>
<input type="email" name="email" class="form-control" value="edkirin@gmail.com">
</div>
<div class="mb-3">
<label class="form-label">Password</label>
<input type="text" name="password" class="form-control" value="tralala">
</div>
<div class="row mt-5">
<div class="col">
<form method="post" action="/">
<div class="mb-3">
<label class="form-label">Email address</label>
<input type="email" name="email" class="form-control" value="edkirin@gmail.com">
</div>
<div class="mb-3">
<label class="form-label">Password</label>
<input type="text" name="password" class="form-control" value="tralala">
</div>
<button type="submit" class="btn btn-success">
Submit
</button>
</form>
<button type="submit" class="btn btn-success">
Submit
</button>
</form>
</div>
<div class="col">
<img src="/static/sample.jpg" class="img-fluid" alt="">
</div>
</div>
<div class="lead">
<p>Bacon ipsum dolor amet leberkas kevin meatball pork loin beef ribs prosciutto, turducken bacon bresaola tri-tip.
Strip steak flank shankle, sirloin short ribs shoulder meatball pork chop kevin ribeye jowl ham pork belly

View File

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

BIN
static/sample.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB