If you want to return a javascript file from disk best to use the static
content view, which in your projects __init__.py would look something like
this:
config.add_static_view('static', 'static', cache_max_age=3600)
Some docs on this
http://docs.pylonsproject.org/projects/pyramid/en/1.0-branch/narr/assets.html
I believe for most Pyramid project templates this'll be configured already.
Then drop the file you want to serve under the static folder.
You can use the JSON renderer and just return a map/list structure from
your view method, check it out in this doc:
http://docs.pylonsproject.org/projects/pyramid/en/1.0-branch/narr/renderers.html#json-json-renderer
or if you need to generate a file on the fly and return it generate the
file and then write it out using the correct headers, which is easy using
FileResponse:
http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/api/response.html#pyramid.response.FileResponse
Just write your generated file to temp disk storage.
On Friday, June 29, 2012 3:35:21 AM UTC-7, Mengu wrote:
>
> you return them like a string but change the content type.
>
> On Jun 29, 8:54 am, no_computer <[email protected]> wrote:
> > how can I return some javascript code or a javascript file with view
> > callables in Pyramid/Pylon framework?
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/pylons-discuss/-/B7vmoK6oXBQJ.
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/pylons-discuss?hl=en.