Hi,
2012/11/4 Dan Shechter <
dan...@gmail.com>:
> Is there a way to manually add HTTP headers to /static pages? I want to
> control the cache for HTTPS static objects.
Here you can see a dummy example that add Content-type header to static files:
import web
import mimetypes
def mime_type(filename):
return mimetypes.guess_type(filename)[0] or 'application/octet-stream'
class Public:
def GET(self):
try:
file_name = web.ctx.path.split('/')[-1]
web.header('Content-type', mime_type(file_name))
return open('./' + web.ctx.path, 'rb').read()
except IOError:
raise web.notfound()
myApp = web.application(mapping=(), fvars=globals())
myApp.add_mapping("/.+", "Public")
myApp.run()
--
Bertera Pietro
http://www.bertera.it