Merge pull request #1 from Code-Club-Crew/add-jagestah

Adding Jagestah 's code
This commit is contained in:
JJ Mckeever 2018-10-04 09:51:45 -06:00 committed by GitHub
commit 69986c034d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 0 deletions

12
jagestah/Dockerfile Normal file
View file

@ -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

14
jagestah/README.md Normal file
View file

@ -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

14
jagestah/app.py Executable file
View file

@ -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'))

View file

@ -0,0 +1 @@
swapi