2xx response for an existing working URL
blueprints with url_prefix started to respond with 308 in the latest flask (used pip)
Please provide a minimal piece of example code demonstrating this issue.
read the issue, code won't be required.
I am getting this after latest version flask install, the whole application works on previous versions
Yes, code is required, because you seem to be the only one with this issue. Also, you didn't mention from which version you updated...
https://github.com/khera-shanu/large/blob/master/app/views/user.py
this is the code
Again, please provide a MINIMAL example demonstrating your issue. That means, a single file/snippet one can run with flask run.
same here.
@khera-shanu
try setting strict_slashes to False
app.url_map.strict_slashes = False
@khera-shanu I ran into this problem when refactoring all of my app's routes into separate Blueprint objects. There seems to be a difference in the defaults of Flask.route and Blueprint.route. The former worked as (I) expected with respect to trailing slashes in the url.
For example
app = Flask(__name__)
@app.route('/user')
def user():
. . .
would work the same whether the request was to /user or /user/.
However, in order to make a Blueprint behave this way, I had to add strict_slashes=False to each of the Blueprint.route calls.
For example
bp = Blueprint('user', __name__, url_prefix='/user')
@bp.route('/', strict_slashes=False)
def user():
. . .
same issue found, and app.url_map.strict_slashes = False not worked for us.
We found if blueprint.route registered route for sub modules, like /api/module1/ for app/module/entrance.py and defined route like route = ['/', ''] in entrance.py,
when request accepted, it will return a 308 response and then a 200 response, some clients like web browser will handle this, some others will not(such like another web service).
We fixed this by redefine route for this situation:route = '/callbak', and now it's working for good.
For anyone coming from google, I got this error when one of my routes had a trailing slash eg.
@app.route("/foo/")
instead of
@app.route("/foo")
Again, for googlers:
This is because of the strict_slahes setting (default True, see https://werkzeug.palletsprojects.com/en/1.0.x/routing/#maps-rules-and-adapters) and this change in Werkzeug:
Most helpful comment
same here.
@khera-shanu
try setting
strict_slashesto False