Solution 1 :

As for me poblem can be because <screening> can match any string – even /process-ticket – and route("<screening>"...) is check as first – before route("/process-ticket")

Flask first compares address /process-ticket with route("<screening>"...) and it matches so it doesn’t check with route("/process-ticket") but runs seat_select(screening="process-ticket").

You have to put function def process_ticket() before def seat_select() and then flask will check address /process-ticket with route("/process-ticket") as first.

Or you should use <int:screening> to match only number and then address /process-ticket will not match to <int:screening>

Problem :

bp_booking = Blueprint('booking', __name__, url_prefix='/booking', template_folder='templates/booking')

@bp_booking.route('<screening>',  methods=["GET", "POST"])
def seat_select(screening):
    cur = db.connection.cursor()
    cur.execute("""SELECT M.title, S.Screening_Start
                    FROM screening S JOIN movie M ON s.movie_id =
                    WHERE = (%s)""", (screening,))
    screening_details = cur.fetchone()
    title = screening_details[0]
    time = screening_details[1].strftime('%d %B  %H:%M')
    cur.execute("""SELECT A.row_count, A.column_count
                    FROM auditorium A JOIN screening S on S.auditorium_id =
                    WHERE = (%s)""", (screening,))
    screen_no = cur.fetchone()
    row = screen_no[0]
    column = screen_no[1]

    return render_template('booking/seatSelect.html', screeningId=screening,
                           title=title, time=time, rows=row, columns=column)

@bp_booking.route('/process-ticket', methods=['GET, POST'])
def process_ticket():
    ticket_value = request.form.get('hidden-ticket-value')
    ## insert into database here
    return 'Ticket inserted into database'


<div id="container">

<div id = "right">
<p id= "quantity">
 Select your seats!

    <form method="POST" action="{{ url_for('booking.process_ticket') }}">
    <input type="hidden" id="hidden" name="hidden-ticket-value">

    <input type="submit" value="Book" id="book-btn">



seatSelect.html has some additonal javascript and css to make a seating plan and the selected seats are stored in the hidden field’s value.

When clicking submit I want to get routed to process-ticket
<form method="POST" action="{{ url_for('booking.process_ticket') }}">
but instead the seat_select(screening) function called called again with the parameter screening=process-ticket
This just throws and error because my function expects a number. Any idea why this is happening?

I tried hardcoding the HTML to take the URL for process_ticket() and the same thing happens.

Edit: I changed the route of select_seat() slightly and now process_ticket() seems to be running but i’m getting a 405 method not allowed error. Should this be happening if methods=['GET, POST'] is present in the function?


Comment posted by furas

always put full error message (starting at word “Traceback”) in question (not comment) as text (not screenshot). There are other useful iformaion.

Comment posted by furas

if you want number then you may need

Comment posted by vremes


Comment posted by user8899578

@furas putting / gives me the same error ( seat_select(screening) function called called again with the parameter screening=process-ticket) , foo/ on the other hand gives the 405 method not allowed eror. I will do so in future but there Isn’t a traceback for the 405 Method not allowed.

Comment posted by furas

as for me poblem can be because