mirror of
https://github.com/arnaucube/kindle-weather.git
synced 2026-01-12 17:01:29 +01:00
Add port flag
This commit is contained in:
9
main.go
9
main.go
@@ -61,11 +61,12 @@ func getOneCall(api string) (*OneCall, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if len(os.Args) != 2 {
|
if len(os.Args) != 3 {
|
||||||
fmt.Println("need an openwathermap.org API key as arg")
|
fmt.Println("need an openwathermap.org API key as arg & port")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
apiKey := os.Args[1]
|
apiKey := os.Args[1]
|
||||||
|
port := os.Args[2]
|
||||||
|
|
||||||
tmpl := template.Must(template.ParseFiles("template.html"))
|
tmpl := template.Must(template.ParseFiles("template.html"))
|
||||||
|
|
||||||
@@ -80,6 +81,6 @@ func main() {
|
|||||||
|
|
||||||
tmpl.Execute(w, data)
|
tmpl.Execute(w, data)
|
||||||
})
|
})
|
||||||
fmt.Println("serving at :8080")
|
fmt.Println("serving at :" + port)
|
||||||
http.ListenAndServe(":8080", nil)
|
http.ListenAndServe(":"+port, nil)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user