bottlepy / bottle

bottle.py is a fast and simple micro-framework for python web-applications.
http://bottlepy.org/
MIT License
8.39k stars 1.47k forks source link

documentation: special methods: OPTIONS #1367

Closed drandreaskrueger closed 2 years ago

drandreaskrueger commented 2 years ago

Why? LibreOffice =WEBSERVICE() before GET always calls OPTIONS and HEAD first.

Solved: Now, to get rid of the 405 error, I only had to add method=['GET', 'HEAD', 'OPTIONS'], like this

@route("/my-endpoint", method=['GET', 'HEAD', 'OPTIONS'])

which is obvious now, but I had not been able to find it in the documentation ...

Suggestion: perhaps add OPTIONS to special methods.


Huge thanks for bottle by the way, using it often, since testing it to be the best, back then (warning: OUTDATED!).

defnull commented 2 years ago

OPTIONS is not handled in any special way by bottle. HEAD and ANY are special, but OPTIONS is just a normal HTTP method you have to explicitly bind to, if you need that. It is more important nowadays because of CORS mechanics, but CORS is best handled in a middleware or before_request hook anyway. Then you would not have to worry about that anymore.