add logs, fix design

This commit is contained in:
2024-11-02 10:20:07 +01:00
parent aed88a5f29
commit e36b15e271
3 changed files with 17 additions and 8 deletions

View File

@@ -10,9 +10,9 @@
<body>
<nav class="navbar navbar-light bg-light">
<span style="margin-left: 1rem;" class="navbar-brand mb-0 h1">DownloadHub</span>
<a style="margin-left: 1rem;" class="navbar-brand mb-0 h1" href="/">DownloadHub</a>
</nav>
<div class="container" style="margin-top: 1rem;">
<div class="container" style="margin-top: 1rem; margin-bottom: 1rem;">
<h2>{{.Name}} ({{.Version}})</h2>
<img width="100%" src="{{index .ScreenshotURLs 0}}" />
<p>{{.Description}}</p>
@@ -32,7 +32,6 @@
</ul>
</div>
</div>
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js"
integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy"

View File

@@ -18,11 +18,11 @@
<div class="col-3">
<img width="100%" src="{{index .ScreenshotURLs 0}}" />
</div>
<div class="col">
<div class="col">
<h2><a href="/d/{{.UUID}}">{{.Name}}</a></h2>
<p>{{.Description}}</p>
</div>
<hr />
<hr style="margin-top: 1rem;" />
</div>
{{end}}
</div>

16
main.go
View File

@@ -4,15 +4,25 @@ import (
"downloadhub/api"
"downloadhub/data"
"flag"
"fmt"
"log/slog"
)
func main() {
var configFile string
flag.StringVar(&configFile, "c", "config.json", "Configuration file path")
var port int
flag.StringVar(&configFile, "c", "config.json", "configuration file path")
flag.IntVar(&port, "p", 3000, "port of the server")
flag.Parse()
slog.Info("loading configuration...")
d := data.Load(configFile)
slog.Info("configuration loaded!")
s := api.New(3000, d)
s.Serve()
slog.Info(fmt.Sprintf("starting server on :%d", port))
s := api.New(uint16(port), d)
err := s.Serve()
if err != nil {
panic(err)
}
}