Skip to content

Commit

Permalink
Add file server
Browse files Browse the repository at this point in the history
  • Loading branch information
abneed committed May 13, 2022
1 parent 4bfdc3e commit 038fb06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/web/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ func routes(app *config.AppConfig) http.Handler {

mux.Get("/", handlers.Repo.Home)
mux.Get("/about", handlers.Repo.About)

fileServer := http.FileServer(http.Dir("./static/"))
mux.Handle("/static/*", http.StripPrefix("/static", fileServer))

return mux
}
4 changes: 4 additions & 0 deletions templates/home.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<div class="col">
<h1>This is the home page</h1>
<p>This is some text</p>
<p>
{{index .StringMap "test"}}
</p>
<img src="/static/images/house.jpg" height="1330" width="2364">
</div>
</div>
</div>
Expand Down

0 comments on commit 038fb06

Please sign in to comment.