From 6d9864f6e070fce9aa49d2abef09070c9ba2823f Mon Sep 17 00:00:00 2001 From: jagestah Date: Thu, 4 Oct 2018 09:51:10 -0600 Subject: [PATCH] Adding Jagestah 's code --- jagestah/Dockerfile | 12 ++++++++++++ jagestah/README.md | 14 ++++++++++++++ jagestah/app.py | 14 ++++++++++++++ jagestah/requirements.txt | 1 + 4 files changed, 41 insertions(+) create mode 100644 jagestah/Dockerfile create mode 100644 jagestah/README.md create mode 100755 jagestah/app.py create mode 100644 jagestah/requirements.txt 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