Merge pull request #1 from Code-Club-Crew/add-jagestah
Adding Jagestah 's code
This commit is contained in:
commit
69986c034d
12
jagestah/Dockerfile
Normal file
12
jagestah/Dockerfile
Normal 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
14
jagestah/README.md
Normal 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
14
jagestah/app.py
Executable 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'))
|
1
jagestah/requirements.txt
Normal file
1
jagestah/requirements.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
swapi
|
Loading…
Reference in a new issue