mirror of
https://github.com/rjNemo/go-wiki
synced 2026-06-06 02:36:40 +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"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strconv"
|
||||
|
||||
"github.com/rjNemo/go-wiki/model"
|
||||
)
|
||||
|
|
@ -23,8 +22,9 @@ func RegisteredRoutes() {
|
|||
log.Fatal(server(Port))
|
||||
}
|
||||
|
||||
func server(p int) error {
|
||||
port := ":" + strconv.Itoa(p)
|
||||
func server(p string) error {
|
||||
port := ":" + p
|
||||
// strconv.Itoa(p)
|
||||
return http.ListenAndServe(port, nil)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,19 @@
|
|||
package controller
|
||||
|
||||
var Port int = 8080
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
var Port string = readEnv(".env")
|
||||
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
|
||||
|
||||
go 1.14
|
||||
|
||||
require github.com/joho/godotenv v1.3.0
|
||||
|
|
|
|||
3
main.go
3
main.go
|
|
@ -8,6 +8,7 @@ import (
|
|||
)
|
||||
|
||||
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()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh"
|
||||
crossorigin="anonymous"
|
||||
/>
|
||||
|
||||
<nav>
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<div class="container">
|
||||
|
|
|
|||
Loading…
Reference in a new issue