如何为pylons静态(公共)文件设置自定义响应头? [英] How can I set a custom response header for pylons static (public) files?

查看:108
本文介绍了如何为pylons静态(公共)文件设置自定义响应头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何向公共服务中添加自定义标头?

How do I add a custom header to files pylons is serving from public?

推荐答案

a)让您的网络服务器提供文件来自/ public而不是paster并将其配置为传递一些特殊标题。

a) Let your webserver serve files from /public instead of paster and configure it to pass some special headers.

b)添加一条特殊路线并自己提供文件ala

b) Add a special route and serve the files yourself ala

class FilesController(BaseController):
    def download(self, path)
        fapp = FileApp( path, headers=self.get_headers(path) )
        return fapp(request.environ, self.start_response)

c)也许有办法覆盖标题,我只是不知道如何。

c) maybe there is a way to overwrite headers and i just dont know how.

这篇关于如何为pylons静态(公共)文件设置自定义响应头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆