flask: 'Float' converter in route not working

In Flask 0.7.2, I have a route defined as:

@app.route('/venues/<float:lat>/<float:lon>/<float:rad>/')

Trying to access that route at http://127.0.0.1/10/20/30 will produce a “404 Not Found” error. If you change the route to

@app.route('/venues/<lat>/<lon>/<rad>/')

or substitute int for float using the conversion notation, then the route works correctly.

About this issue

  • Original URL
  • State: closed
  • Created 13 years ago
  • Comments: 21 (7 by maintainers)

Most upvoted comments

That is a mistake. -32.234 is negative and is a float too, so it should definitely be accepted when calling <float:my_number>. Keeping this mistake alive by not wanting to break existing apps is a thing, but one cannot call it a proper behaviour. If this is by design, then the design is broken.

I’m just here to say that the way negative numbers aren’t recognised by the float converter tripped me up too (and googling about it brought me here).

@app.route('/venues/<int:lat>/<int:lon>/<int:rad>/')
@app.route('/venues/<float:lat>/<float:lon>/<float:rad>/')

It works for integers and floats.