Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to return javascript in Pyramid/Pylon

how can I return some javascript code or a javascript file with view callables in Pyramid/Pylon framework?

like image 421
Jensen Avatar asked Nov 29 '25 04:11

Jensen


1 Answers

You can do that as you'd do with any template/view callable. It's not that different. I'd still recommend setting the content type as such.

from pyramid.view import view_config

@view_config(name='javascript', renderer='templates/javascript.mako')
def my_js_view(request):
    request.response.content_type = 'application/javascript'
    return {... params ...}

It doesn't really differ from other views.

like image 116
Loïc Faure-Lacroix Avatar answered Dec 01 '25 18:12

Loïc Faure-Lacroix



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!