langdev.web.wsgi — Custom WSGI middlewares

class langdev.web.wsgi.MethodRewriteMiddleware(application)

The WSGI middleware that overrides HTTP methods for old browsers. HTML4 and XHTML only specify POST and GET as HTTP methods that <form> elements can use. HTTP itself however supports a wider range of methods, and it makes sense to support them on ther server.

If you however want to make a form submission with PUT for instance, and you are using a client that does not support it, you can override it by using this middleware and appending ?__method__=PUT to the <form> action.

<form action="?__method__=put" method="post">
  ...
</form>
Parameters:application (callable object) – WSGI application to wrap
class langdev.web.wsgi.HostRewriteMiddleware(application, host=None, config_name='HOST_REWRITE')

A WSGI middleware that overwrites every request’s Host header (that is, HTTP_HOST environment) to the specific host name. It is useful when WSGI server is running under proxy server.

Parameters:
  • application (callable object, flask.Flask) – WSGI application to wrap
  • host (basestring) – a host name to rewrite. if not present, HOST_REWRITE configuration may be used (only when application is a flask.Flask instance)

Project Versions

Previous topic

langdev.web.serializers — Serializers for various content types

Next topic

langdev.util — Utilities

This Page