Merge pull request 'feat: add automatic serving of index.html in directory' (#5) from supitszaire/indir:main into main
Reviewed-on: https://codeberg.org/arimelody/indir/pulls/5 Reviewed-by: ari melody <ari@arimelody.space>
This commit is contained in:
commit
9333574de2
3 changed files with 24 additions and 15 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -2,3 +2,5 @@
|
|||
tmp
|
||||
indir
|
||||
indir-*
|
||||
.zed
|
||||
index.html
|
||||
|
|
|
|||
7
main.go
7
main.go
|
|
@ -172,6 +172,13 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
// serve index.html if present (case-sensitive)
|
||||
indexPath := filepath.Join(fpath, "index.html")
|
||||
if _, err := os.Stat(indexPath); err == nil {
|
||||
http.ServeFile(w, r, indexPath)
|
||||
return
|
||||
}
|
||||
|
||||
// embeded readme
|
||||
var readmeHTML template.HTML
|
||||
entries, err := os.ReadDir(fpath)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue