-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51d7d2d
commit f8f179b
Showing
4 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
Section_3_Your_first_REST_API/Lec_55_Your_first_REST_API_endpoint.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Lec_55_Your_first_REST_API_endpoint.md | ||
|
||
Picking up from last lecture | ||
|
||
```py | ||
from flask import Flask | ||
|
||
app = Flask(__name__) # Creates flask app that does a lot for us | ||
``` | ||
|
||
Going to put the data in a python list, DB later. | ||
|
||
```py | ||
from flask import Flask | ||
|
||
app = Flask(__name__) # Creates flask app that does a lot for us | ||
|
||
stores = [ | ||
{ | ||
"name": "My Store", | ||
"items": [ | ||
{ | ||
"name": "Chair", | ||
"price": 15.99 | ||
} | ||
] | ||
} | ||
] | ||
|
||
@app.get("/store") # Endpoint. http://127.0.0.1:5000/store | ||
def get_stores(): | ||
return {"stores": stores} | ||
|
||
``` | ||
|
||
Returns: | ||
|
||
 | ||
|
||
Spaces and tabs don't matter in JSON. Order does not matter in JSON. | ||
|
||
We'll talk about what JSON is in the next lecture. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
from flask import Flask | ||
|
||
app = Flask(__name__) # Creates flask app that does a lot for us | ||
|
||
stores = [ | ||
{ | ||
"name": "My Store", | ||
"items": [ | ||
{ | ||
"name": "Chair", | ||
"price": 15.99 | ||
} | ||
] | ||
} | ||
] | ||
|
||
|
||
@app.get("/store") # Endpoint. http://127.0.0.1:5000/store | ||
def get_stores(): | ||
return {"stores": stores} |