-
Notifications
You must be signed in to change notification settings - Fork 0
/
StuVariableRuleAppPy.py
45 lines (33 loc) · 1.28 KB
/
StuVariableRuleAppPy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from flask import Flask, jsonify
justice_league_members = [
{"superhero": "Aquaman", "real_name": "Arthur Curry"},
{"superhero": "Batman", "real_name": "Bruce Wayne"},
{"superhero": "Cyborg", "real_name": "Victor Stone"},
{"superhero": "Flash", "real_name": "Barry Allen"},
{"superhero": "Green Lantern", "real_name": "Hal Jordan"},
{"superhero": "Superman", "real_name": "Clark Kent/Kal-El"},
{"superhero": "Wonder Woman", "real_name": "Princess Diana"}
]
#################################################
# Flask Setup
#################################################
app = Flask(__name__)
#################################################
# Flask Routes
#################################################
@app.route("/api/v1.0/justice-league")
def justice_league():
"""Return the justice league data as json"""
return jsonify(justice_league_members)
@app.route("/")
def welcome():
return (
f"Welcome to the Justice League API!<br/>"
f"Available Routes:<br/>"
f"/api/v1.0/justice-league<br/>"
f"/api/v1.0/justice-league/superhero/batman"
)
"""TODO: Handle API route with variable path to allow getting info
for a specific character based on their 'superhero' name """
if __name__ == "__main__":
app.run(debug=True)