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,23 +4,30 @@
{{ 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">
<div class="mb-3"> <form method="post" action="/">
<label class="form-label">Email address</label> <div class="mb-3">
<input type="email" name="email" class="form-control" value="edkirin@gmail.com"> <label class="form-label">Email address</label>
</div> <input type="email" name="email" class="form-control" value="edkirin@gmail.com">
<div class="mb-3"> </div>
<label class="form-label">Password</label> <div class="mb-3">
<input type="text" name="password" class="form-control" value="tralala"> <label class="form-label">Password</label>
</div> <input type="text" name="password" class="form-control" value="tralala">
</div>
<button type="submit" class="btn btn-success"> <button type="submit" class="btn btn-success">
Submit Submit
</button> </button>
</form> </form>
</div>
<div class="col">
<img src="/static/sample.jpg" class="img-fluid" alt="">
</div>
</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.
Strip steak flank shankle, sirloin short ribs shoulder meatball pork chop kevin ribeye jowl ham pork belly 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 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