added arguments checking

This commit is contained in:
Jacob 2017-11-07 12:47:37 +01:00
parent baec822129
commit 80e925baf5

View File

@ -4,6 +4,7 @@ import (
"html/template"
"net/http"
"strings"
"os"
)
type Page struct {
@ -18,11 +19,22 @@ var sections = []string {"about","past", "contact"}
var templates = template.Must(template.ParseFiles("blog.tmpl", "blog_roll.tmpl", "style.tmpl", "post.tmpl"))
func main() {
http.HandleFunc("/", blogHandler)
http.HandleFunc("/post/", postHandler)
if os.Args[1] == "local" {
http.ListenAndServe(":8080", nil)
}
if os.Args[1] == "ext" {
http.ListenAndServe(":35291", nil)
}
//http.ListenAndServe(":8080", nil)
}
func blogHandler(w http.ResponseWriter, req *http.Request) {
posts = getNewestPosts(3)
page := Page {name, sections, posts}