Browse Source

Save one file per mensa/day

vuex
Schneider 8 years ago
parent
commit
65011ad668
  1. 2
      .gitignore
  2. 29
      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

29
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())
return
}
menus = append(menus, menu)
}
}
bytes, err := json.Marshal(menus)
if err != nil {
fmt.Println(err.Error())
}
content, err := json.Marshal(menu)
if err != nil {
fmt.Println(err.Error())
return
}
if len(os.Args) == 2 {
err = writeToFile(bytes)
if err != nil {
fmt.Println(err.Error())
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