Browse Source

Save one file per mensa/day

vuex
Schneider 8 years ago
parent
commit
65011ad668
  1. 2
      .gitignore
  2. 19
      server/server.go

2
.gitignore

@ -4,3 +4,5 @@ dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
static/*heute.json
static/*morgen.json

19
server/server.go

@ -37,30 +37,31 @@ var (
)
func main() {
menus := []Menu{}
path := "./"
if len(os.Args) == 2 {
path = os.Args[1] + "/"
}
for _, mensa := range mensen {
for _, day := range days {
menu, err := operate(mensa, day)
if err != nil {
fmt.Println(err.Error())
}
menus = append(menus, menu)
}
return
}
bytes, err := json.Marshal(menus)
content, err := json.Marshal(menu)
if err != nil {
fmt.Println(err.Error())
return
}
if len(os.Args) == 2 {
err = writeToFile(bytes)
err = ioutil.WriteFile(fmt.Sprintf("%s/%s.%s.json", path, mensa, day), content, 0644)
if err != nil {
fmt.Println(err.Error())
return
}
}
} else {
fmt.Println(string(bytes))
}
}

Loading…
Cancel
Save