[Grok-dev] Get files
Sebastian Ware
sebastian at urbantalk.se
Fri Mar 19 11:33:06 EDT 2010
if you store files in src/[appname]/static they will be reachable with
host:port/[app_instance_name]/@@/[appname]/path/relative/to/
static.pdf
You can also create a view that returns files you have stored on the
filesystem:
class Index(grok.View):
grok.name('index.html')
grok.require('zope.Public')
def render(self):
self.response.setHeader('Content-Disposition', 'inline')
self.response.setHeader('Content-Type',
self.context.content_type)
file = open('local/file/system/path.pdf', 'rb')
data = file.read()
file.close()
return data
I think you get the general idea.
You can also check out
http://grok.zope.org/documentation/how-to/uploading-file
http://grok.zope.org/about/useful-libraries
Mvh Sebastian
18 mar 2010 kl. 16.43 skrev zavi:
>
> Hi,
>
> I'm new to grok (and web servers in general unfortunately).
> I'm using Grok with Apache/mod_wsgi, and managed to build and run some
> simple example apps.
> What I want to do next is to build an app that serves files.
> That is, when I send an http request which specifies a file name, I
> would
> like to send back that file.
>
> However I could not find an example for such a simple grok app.
> I would appreciate your help
>
> Thanks
>
> --
> View this message in context: http://old.nabble.com/Get-files-tp27947412p27947412.html
> Sent from the Grok mailing list archive at Nabble.com.
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> https://mail.zope.org/mailman/listinfo/grok-dev
More information about the Grok-dev
mailing list