Do not fail when file has no game data
parent
717209a7f1
commit
edaf64ea5c
|
@ -35,5 +35,6 @@ get "/data/:game/:file.json" do |game, file|
|
||||||
data_file = File.expand_path(File.join(settings.data_folder, game, "#{file}.yml"))
|
data_file = File.expand_path(File.join(settings.data_folder, game, "#{file}.yml"))
|
||||||
halt(404) unless File.exist?(data_file)
|
halt(404) unless File.exist?(data_file)
|
||||||
|
|
||||||
json YAML.load_file(data_file)['data'].sample
|
data = YAML.load_file(data_file)['data']
|
||||||
|
json Array(data).sample
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue