使用 Flask-Assets 访问 URL 时出现以下错误,该 URL 应该呈现和缩小 css。
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
以下是包含 Flask-Assets 的代码
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
HTML
{% assets "css_all" %}
<link rel="stylesheet" href="{{ ASSET_URL }}"/>
{% endassets %}
文件夹结构
.
├── 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
4个目录,9个文件