Skip to content

Commit b94f485

Browse files
author
Jose Salvatierra
committed
Fixed a couple bugs in the code.
1 parent 7be6f04 commit b94f485

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

section3/app.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
app = Flask(__name__)
44

5-
stores = {
5+
stores = [{
66
'name': 'My Store',
77
'items': {'name':'my item', 'price': 15.99 }
8-
}
8+
}]
99

1010
@app.route('/')
1111
def home():
@@ -23,13 +23,13 @@ def create_store():
2323
return jsonify(new_store)
2424
#pass
2525

26-
#get /store/<string_name> data: {name :}
27-
@app.route('/store/<string_name>')
26+
#get /store/<name> data: {name :}
27+
@app.route('/store/<string:name>')
2828
def get_store(name):
2929
for store in stores:
3030
if store['name'] == name:
3131
return jsonify(store)
32-
return jsonify ({'message':'store not found'})
32+
return jsonify ({'message': 'store not found'})
3333
#pass
3434

3535
#get /store
@@ -38,8 +38,8 @@ def get_stores():
3838
return jsonify(stores)
3939
#pass
4040

41-
#post /store/<string_name> data: {name :}
42-
@app.route('/store/<string_name>/item' , methods=['POST'])
41+
#post /store/<name> data: {name :}
42+
@app.route('/store/<string:name>/item' , methods=['POST'])
4343
def create_item_in_store(name):
4444
request_data = request.get_json()
4545
for store in stores:
@@ -53,8 +53,8 @@ def create_item_in_store(name):
5353
return jsonify ({'message' :'store not found'})
5454
#pass
5555

56-
#get /store/<string_name>/item data: {name :}
57-
@app.route('/store/<string_name>/item')
56+
#get /store/<name>/item data: {name :}
57+
@app.route('/store/<string:name>/item')
5858
def get_item_in_store(name):
5959
for store in stores:
6060
if store['name'] == name:

0 commit comments

Comments
 (0)