diff --git a/jagestah/Dockerfile b/jagestah/Dockerfile new file mode 100644 index 0000000..09f56fd --- /dev/null +++ b/jagestah/Dockerfile @@ -0,0 +1,12 @@ +FROM alpine:latest +WORKDIR /app +ADD . /app +RUN apk update && apk add \ + py-pip \ + python \ + python-dev \ + alpine-sdk +RUN pip install --upgrade pip +RUN pip install \ + swapi +CMD python app.py \ No newline at end of file diff --git a/jagestah/README.md b/jagestah/README.md new file mode 100644 index 0000000..1758a7d --- /dev/null +++ b/jagestah/README.md @@ -0,0 +1,14 @@ + +# Purpose + +Connect to the Star Wars API located at http://swapi.co and return a list of Starships that have a named pilots and then name those Pilots. + + + +# Directions + +The Docker image has already been built and published to jagestah/swapitest + +With docker installed on your system it should be as simple as `docker run jagestah/swapitest` + +This Repo contains the documents used to build the Docker image diff --git a/jagestah/app.py b/jagestah/app.py new file mode 100755 index 0000000..17d7ea4 --- /dev/null +++ b/jagestah/app.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +import swapi +import requests + +ships = (swapi.get_all("starships")) +print (ships) + +for ship in ships.iter(): + if len(ship.pilots) > 0: + print(ship.name) + for pilot in ship.pilots: + response = requests.get(pilot) + data = response.json() + print(" "+data["name"].encode('utf-8')) \ No newline at end of file diff --git a/jagestah/requirements.txt b/jagestah/requirements.txt new file mode 100644 index 0000000..a1e9c69 --- /dev/null +++ b/jagestah/requirements.txt @@ -0,0 +1 @@ +swapi \ No newline at end of file