OSError: [Errno 78] Function not implemented Flask-Assets
<p>I get the following error when accessing a URL with Flask-Assets which is supposed to render and minify css. </p>

<pre><code>ERROR    2016-09-01 02:45:00,096 app.py:1587] Exception on /SomeFile [GET]
Traceback (most recent call last):
  File "/Users/vinay/App-Engine/zion-alpha/lib/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/vinay/App-Engine/zion-alpha/lib/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/vinay/App-Engine/zion-alpha/lib/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/vinay/App-Engine/zion-alpha/lib/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/vinay/App-Engine/zion-alpha/lib/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/vinay/App-Engine/zion-alpha/app/routes/home_routes.py", line 14, in show_file
    return render_template('main.html')
  File "/Users/vinay/App-Engine/zion-alpha/lib/flask/templating.py", line 134, in render_template
    context, ctx.app)
  File "/Users/vinay/App-Engine/zion-alpha/lib/flask/templating.py", line 116, in _render
    rv = template.render(context)
  File "/Users/vinay/App-Engine/zion-alpha/lib/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/Users/vinay/App-Engine/zion-alpha/lib/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/vinay/App-Engine/zion-alpha/app/templates/main.html", line 6, in top-level template code
    {% assets "css_all" %}
OSError: [Errno 78] Function not implemented
INFO     2016-09-01 02:45:00,116 module.py:788] default: "GET /SomeFile HTTP/1.1" 500 291
INFO     2016-09-01 02:45:00,853 module.py:402] [default] Detected file changes:
  /Users/vinay/App-Engine/zion-alpha/app
</code></pre>

<p>The following is the code containing Flask-Assets</p>

<pre><code>def create_app():
    """Create the Flask App"""
    app = Flask(__name__)
    configure_blueprints(app)
    css = Bundle('css/main.css',
                 'css/main2.css',
                 filters="cssmin",
                 output="static/css/min.css"
                 )
    assets = Environment(app)
    assets.register('css_all', css)
    return app
</code></pre>

<p>HTML</p>

<pre><code>{% assets "css_all" %}
    &lt;link rel="stylesheet" href="{{ ASSET_URL }}"/&gt;
{% endassets %}
</code></pre>

<p>Folder structure</p>

<pre><code>.
âââ admin
âÂ Â  âââ __init__.py
âÂ Â  âââ __init__.pyc
âÂ Â  âââ routes
âÂ Â  âÂ Â  âââ __init__.py
âÂ Â  âÂ Â  âââ __init__.pyc
âÂ Â  âÂ Â  âââ admin_routes.py
âÂ Â  âÂ Â  âââ admin_routes.pyc
âÂ Â  âââ static
âÂ Â  âÂ Â  âââ css
âÂ Â  âÂ Â      âââ admin-2.css
âÂ Â  âÂ Â      âââ admin.css
âÂ Â  âââ templates
âÂ Â      âââ adminindex.html
âââ app
âÂ Â  âââ __init__.py
âÂ Â  âââ __init__.pyc
âÂ Â  âââ routes
âÂ Â  âÂ Â  âââ __init__.py
âÂ Â  âÂ Â  âââ __init__.pyc
âÂ Â  âÂ Â  âââ home_routes.py
âÂ Â  âÂ Â  âââ home_routes.pyc
âÂ Â  âââ static
âÂ Â  âÂ Â  âââ css
âÂ Â  âÂ Â      âââ main.css
âÂ Â  âÂ Â      âââ main2.css
âÂ Â  âââ templates
âÂ Â      âââ main.html
âââ app.yaml
âââ appengine_config.py
âââ appengine_config.pyc
</code></pre>

<p>4 directories, 9 files</p>

<p>This seems to be a problem with <code>flask-assets</code> and Google App Engine because GAE disallows file creation at run-time.</p>

<p>Possible duplicate of: <a href="http://stackoverflow.com/questions/17150096/gae-flask-webassets-throws-an-expection-on-extends-base-html">GAE: Flask/webassets throws an expection on {% extends &quot;base.html&quot; %}</a></p>

<p>Either minify the css before deploying to GAE, or find a different method of serving the minified css either at runtime (not preferred) or buildtime (preferred).</p>

<p>One possibility is to create the minified js on the first run (buildtime), which can then be uploaded to a google storage bucket.</p>

<p>Another option is to create the minified js at runtime and keep it stored in a memcache.</p>

python flask-assets