view light9/coffee.py @ 1939:6f49dc917aa3

start vidref web version. v4l camera frames to web page is working Ignore-this: 34bcc3b6149a1a3bed31aa5f32a4ddc6
author Drew Perttula <drewp@bigasterisk.com>
date Mon, 03 Jun 2019 09:50:29 +0000
parents 3c523c71da29
children
line wrap: on
line source

from cycloneerr import PrettyErrorHandler
import cyclone.web
import subprocess


class StaticCoffee(PrettyErrorHandler, cyclone.web.RequestHandler):
    """
    e.g.

            (r'/effect\.js', StaticCoffee, {
                'src': 'light9/effecteval/effect.coffee'
            }),
    """ # noqa

    def initialize(self, src):
        super(StaticCoffee, self).initialize()
        self.src = src

    def get(self):
        self.set_header('Content-Type', 'application/javascript')
        self.write(
            subprocess.check_output(
                ['/usr/bin/coffee', '--compile', '--print', self.src]))