Hi,
2012/11/4 Dan Shechter <[email protected]>:
> 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
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/webpy?hl=en.