Часть кода
def wishListCount():
wishlist_count = len(session['Wishlist'])
if len(session['Wishlist']) <= 0:
return 0
else:
return wishlist_count
@app.route('/wishlist', methods=['GET', 'POST', 'DELETE'])
def wishlist():
if request.method == 'POST':
product_id = int(request.form['product_id'])
ListItems = [product_id]
if 'Wishlist' in session:
if product_id in session['Wishlist']:
print("This product is already in wishList!")
else:
session['Wishlist'] = mergeDict(session['Wishlist'], ListItems)
else:
session['Wishlist'] = ListItems
wishlist_count = wishListCount()
Журналы Heroku
Состояние изменено с начала на
2020-05 -07T00: 37: 33.000000 + 00: 00 app [api]: Сборка завершена
2020-05-07T00: 37: 39.445026 + 00: 00 heroku [router]: at = info method = GET path = " / "host = intelli-supermart.herokuapp.com request_id = bc70627f-fbff-4722-8b7e-f97c18e7e2d5 fwd =" 203.128.16.105 "dyno = web.1 connect = 1ms service = 102ms status = 500 байт = 470 протокол = https
2020-05-07T00: 37: 39.441994 + 00: 00 app [web.1]: [2020-05-07 00: 37: 39,440] ОШИБКА в приложении: исключение на / [GET]
2020-05-07T00: 37: 39.442004 + 00: 00 app [web.1]: Traceback (последний вызов последний):
2020-05-07T00: 37: 39.442005 + 00: 00 app [web.1]: файл "/app/.heroku/python/lib/python3.6/site packages / flask / app.py", строка 2447, в wsgi_app
2020-05- 07T00: 37: 39.442005 + 00: 00 app [web.1]: response = self.full_dispatch_request ()
2020-05-07T00: 37: 39.442006 + 00: 00 app [web.1]: Файл "/app/.heroku/python/l ib / python3 .6 / site- packages / flask / app.py ", строка 1952, в full_dispatch_request
2020-05-07T00: 37: 39.442006 + 00: 00 app [web.1]: rv = self.handle_user_exception (e)
2020-05-07T00: 37: 39.442007 + 00: 00 app [web.1]: Файл "/app/.heroku/python/lib/python3. 6 / site-packages / flask / app.py ", строка 1821, в handle_user_exception
2020-05-07T00: 37: 39.442007 + 00: 00 app [web.1]: reraise (exc_type, exc_value, tb)
2020-05-07T00: 37: 39.442007 + 00: 00 app [web.1]: Файл "/app/.heroku/python/lib/python3.6/site-packages/ flask / _compat.py ", строка 39, повторное повышение
2020-05-07T00: 37: 39.442008 + 00: 00 app [web.1]: значение повышения
2020-05- 07T00: 37: 39.442009 + 00: 00 app [web.1]: Файл "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", строка 1950, в full_dispatch_request
2020-05-07T00: 37: 39.442009 + 00: 00 app [web.1]: rv = self.dispatch_request ()
2020-05-07T00: 37: 39.442009 + 00 : 00 приложение [web.1]: Файл "/app/.heroku/python/lib/python3.6/site-packages/flas k / app.py ", строка 1936, в dispatch_request
2020-05-07T00: 37: 39.442010 + 00: 00 app [web.1]: return self.view_functionsrule.endpoint
2020-05-07T00: 37: 39.442010 + 00: 00 app [web.1]: файл «/app/app.py», строка 117, в индексе
2020-05-07T00: 37: 39.442011 +00: 00 app [web.1]: wishlist_count = wishListCount ()
2020-05-07T00: 37: 39.442011 + 00: 00 app [web.1]: Файл "/app/app.py ", строка 79, в wishListCount
2020-05-07T00: 37: 39.442011 + 00: 00 app [web.1]: wishlist_count = len (session ['Wishlist'])
2020-05-07T00: 37: 39.442012 + 00: 00 app [web.1]: Файл "/app/.heroku/python/lib/python3.6/site-packages/werkzeug/local.py", строка 377, в
2020-05-07T00: 37: 39.442012 + 00: 00 app [web.1]: getitem = лямбда x, i: x._get_current_object () [i]
2020-05-07T00: 37: 39.442012 + 00:00 app [web.1]: Файл "/app/.heroku/python/lib/python3.6/site-packages/flask/ sessions.py ", строка 84, в приложении getitem
2020-05-07T00: 37: 39.442013 + 00:00 [web.1]: return super (SecureCookieSession, self). getitem (key)
2020-05-07T00: 37: 39.442019 + 00: 00 app [web.1]: KeyError: 'Wishlist'
2020-05-07T00: 37: 39.445086 + 00: 00 app [web.1]: 10.11.150.203 - - [07 / May / 2020: 00: 37: 39 +0000 ] "GET / HTTP / 1.1" 500 290 "-" "Mozilla / 5.0 (X11; Linux x86_64) AppleWebKit / 537.36 (K HTML, как Gecko) Chrome / 81.0.4044.122 Safari / 537.36 "