Python Middleware Generator