Skip to content

Instantly share code, notes, and snippets.

@mlusiak
Created April 15, 2017 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlusiak/b00a756b891e701354cba66fae55bd78 to your computer and use it in GitHub Desktop.
Save mlusiak/b00a756b891e701354cba66fae55bd78 to your computer and use it in GitHub Desktop.
defmodule Flightlog.FlightView do
use Flightlog.Web, :view
def download(airport) do
url = "https://airportapi02560c297e8.azurewebsites.net/api/Airports?code={not_that_important}&iataCode=" <> airport
response = HTTPotion.get url
{status, fields} = JSON.decode(response.body)
fields
end
def lat(airport) do
fields = download(airport)
fields["lat@"]
end
def lon(airport) do
fields = download(airport)
fields["lon@"]
end
def location(airport) do
fields = download(airport)
fields["city@"] <> ", " <> fields["country@"]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment