[Grok-dev] Get files
Steve Schmechel
steveschmechel at yahoo.com
Fri Mar 19 11:45:17 EDT 2010
In the simplest sense, if all you want to do is serve static files a web
server like Apache does that quite well and you do not need a web
application built using Grok.
Of course, even a web application needs to serve up static files at
times. Generally, these are image files and style sheets that are used
with the pages generated by the web application.
To serve this type of content, just place the files in the "static"
directory located under the project folder created by grokproject.
You can then access the files from the browser by appending
"@@/<project name>/<filename> to the URL of an application instance.
(i.e. http://localhost:8080/myapp/@@/myproject/mypicture.jpg)
This is rather clumsy, so if you are using page templates you can define
the static files there, and it will handle all the details.
(i.e. <a tal:attributes="href static/mypicture.jpg">See my picture.</a>
-- or --
<link rel="stylesheet" type="text/css" tal:attributes="href static/adder.css">)
See this documentation for more details:
http://grok.zope.org/doc/current/grok_overview.html#static-content
If you end up dealing with lots of resource-type files (Javascript
libraries, etc) included in your application, you may want to look at
something like megrok.resource to make managing these files easier.
http://grok.zope.org/about/useful-libraries#static-resource-handling
If you want to deal with user-supplied static files, including being
able to upload, download and delete them, you need to look into file
utilities. The following how-to should help you get started:
http://grok.zope.org/documentation/how-to/uploading-file
Hope this helps,
Steve
--- On Thu, 3/18/10, zavi <osishkin at gmail.com> wrote:
> From: zavi <osishkin at gmail.com>
> Subject: [Grok-dev] Get files
> To: grok-dev at zope.org
> Date: Thursday, March 18, 2010, 10:43 AM
>
> 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