mirror of
https://github.com/rjNemo/go-wiki
synced 2026-06-12 13:36:38 +00:00
home page layout
This commit is contained in:
parent
7d66d09abf
commit
5ffc5224c4
5 changed files with 24 additions and 5 deletions
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/rjNemo/go-wiki/model"
|
"github.com/rjNemo/go-wiki/model"
|
||||||
)
|
)
|
||||||
|
|
@ -23,8 +22,9 @@ func RegisteredRoutes() {
|
||||||
log.Fatal(server(Port))
|
log.Fatal(server(Port))
|
||||||
}
|
}
|
||||||
|
|
||||||
func server(p int) error {
|
func server(p string) error {
|
||||||
port := ":" + strconv.Itoa(p)
|
port := ":" + p
|
||||||
|
// strconv.Itoa(p)
|
||||||
return http.ListenAndServe(port, nil)
|
return http.ListenAndServe(port, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,19 @@
|
||||||
package controller
|
package controller
|
||||||
|
|
||||||
var Port int = 8080
|
import (
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/joho/godotenv"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Port string = readEnv(".env")
|
||||||
var tmplDir string = "templates/"
|
var tmplDir string = "templates/"
|
||||||
|
|
||||||
|
func readEnv(f string) string {
|
||||||
|
err := godotenv.Load(".env")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Error loading .env file")
|
||||||
|
}
|
||||||
|
return os.Getenv("PORT")
|
||||||
|
}
|
||||||
|
|
|
||||||
2
go.mod
2
go.mod
|
|
@ -1,3 +1,5 @@
|
||||||
module github.com/rjNemo/go-wiki
|
module github.com/rjNemo/go-wiki
|
||||||
|
|
||||||
go 1.14
|
go 1.14
|
||||||
|
|
||||||
|
require github.com/joho/godotenv v1.3.0
|
||||||
|
|
|
||||||
3
main.go
3
main.go
|
|
@ -8,6 +8,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
fmt.Printf("Start Go-wiki server on http://localhost:%d at %s\n", controller.Port, time.Now())
|
|
||||||
|
fmt.Printf("Start Go-wiki server on http://localhost:%s at %s\n", controller.Port, time.Now())
|
||||||
controller.RegisteredRoutes()
|
controller.RegisteredRoutes()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh"
|
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh"
|
||||||
crossorigin="anonymous"
|
crossorigin="anonymous"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue