evansd / whitenoise

Radically simplified static file serving for Python web apps
https://whitenoise.readthedocs.io
MIT License
2.55k stars 151 forks source link

Should not handle POST, PUT or DELETE HTTP methods? #465

Closed n1ngu closed 1 year ago

n1ngu commented 1 year ago

Python Version

3.11.1

Django Version

NA

Package Version

6.3.0

Description

I am trying to deploy whitenoise alongside an RPC application that happens to have a control endpoint on the root path.

I was eager to deploy whitenoise with the https://whitenoise.evans.io/en/latest/base.html#index-files feature so that GET /index.html would redirect to the root path and GET / would serve the index content.

To my unamusement POST / now throws an error instead of being served from the RPC application!

Generally, a POST, PUT or DELETE on a path that happens to exist both in the WSGI application and as a static file and will be captured by whitenoise middleware. I'd expect GET, HEAD and OPTIONS methods to use the static file but POST, PUT and DELETE requests be forwarded to the WSGI app?

This might be a rare cornercase, but the framework I work with forces me to deploy both the app and the static files in the same path.

merwok commented 1 year ago

Can you show some config?

adamchainz commented 1 year ago

I don’t think we’d want to support splitting destination based on request method. If the URL is captured by Whitenoise, it’s handled by Whitenoise, regardless of method. If you need to serve an index file on GET and do something else on POST, do that within your application.