-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cedar - Jacy & Kit #15
base: main
Are you sure you want to change the base?
Changes from 6 commits
c5a9bfc
eb71eb6
3d7bffd
9cf827e
39c4dd7
6d98074
b42cc8f
0b775b2
45c7886
a29a3af
9a0acd4
3c2ff79
54be1bb
7884f06
7d7a32f
2628ed7
c737a22
f1e3085
c673c70
778f1ef
7caf8d2
08d0db3
9bd9398
45f4ace
edf2bfc
351d71d
8aafbfb
42e0d2c
19ece10
54abab4
49302c3
67b3bf4
9af523e
663d89a
8b5fa84
b54163c
ca7eb00
2e2e587
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,39 @@ | ||
from flask import Blueprint | ||
# localhost:5000/ <-- add url endpoint/parameters here | ||
|
||
from flask import Blueprint, jsonify | ||
|
||
|
||
class Planet(): | ||
def __init__(self, id, name, description, xenomorphs=False): | ||
self.id = id | ||
self.name = name | ||
self.description = description | ||
self.xenomorphs = xenomorphs | ||
|
||
|
||
PLANETS = [ | ||
|
||
Planet(426, "Nostromo's End", "Hostile weather. Toxic atmosphere. Evidence of civilization.", True), | ||
Planet(224, "JollyPlanet", "Okay. Decent. Will live for long time.", True) | ||
|
||
] | ||
|
||
planets_bp = Blueprint("planets_bp", __name__, url_prefix="/planets") | ||
|
||
# @blueprint_name.route("/endpoint/path/here", methods=["GET"]) | ||
@planets_bp.route("", methods=["GET"]) | ||
def get_all_planets(): | ||
planets_response = [] | ||
|
||
for planet in PLANETS: | ||
planets_response.append(vars(planet)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice use of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just learned that |
||
|
||
return jsonify(planets_response) | ||
|
||
@planets_bp.route("/<planet_id>", methods=["GET"]) | ||
def get_planet(planet_id): | ||
planet_id = int(planet_id) | ||
|
||
for planet in PLANETS: | ||
if planet.id == planet_id: | ||
return vars(planet) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor note, consider moving extra spaces: