Dynamic route returns favicon.ico instead of variable in Flask

Viewed 54

Good afternoon,

I am currently developing a Flask application, and I am experiencing an error that had never happened to me before. I am currently setting up a dynamic route in Flask. This is the piece of code:

@app.route('/viewcar/<string:carId>')
def viewcar(carId):
    print(carId)
    car = Car.getCarById(carId)
    return render_template("car.html", car=car)

However, when I pass any variable to the URL (let's say "http://127.0.0.1:5000/viewcar/4975facbbce511b65e14f44719340029-cf161184-91fc"), when I check the output in the console, it says that carId equals to favicon.ico instead of "4975facbbce511b65e14f44719340029-cf161184-91fc". Any ideas on what could this be? It has never happened to me before. Thanks in advance.

2 Answers

I just ran into this issue today too, however I noticed that when I launch my development flask server at http://127.0.0.1:5000/ in Chrome (version 104.0.5112.101), the console logs show that it grabbed favicon.ico for the variable I was grabbing from the URL, but when I used Safari (version 15.3) the URL variable was correctly parsed.

Now I'm starting to think it's a browser related?

I'm really new to flask myself and also came across this issue. For me it was that I had another route in my module that got executed prior to this route I intended and the variable name was being assigned there so it seems the next (default?) argument must have been used in my intended route. I'm sure I'm only describing this halfway correct but hopefully it helps somebody debug their issue a little quicker.

Related