Create middleware.py

PEP8 compliant