Adding Jagestah

's code
This commit is contained in:
jagestah 2018-10-04 09:51:10 -06:00
parent ef790d5dad
commit 6d9864f6e0
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